Hi ,in a template based widget, I have a table in a template and the table’s body will be constructed
In my widget using domConstruct.
The problem is that The click event of “a” element does not work. Actually nothing happens when I click on it and the logging does not show any error or massage.( the other click events in My template work fine) the problem only is with this event that is made using domConstruct programmatically.please help me.
As I told everything work fine, the template widget work fine .the only problem is the below click event that does not work.
Thanks in advance
for (var i = 0; i < result.features.length; i++) {
domConstruct.place(lang.replace('<tr><td><a class="zoomto" data-dojo-attach- event="ondijitclick:zoomto">{t0}</a></td><td>{t1}</td><td>{t2}</td><td>{t3}</td></tr>',{
t0:i + 1,
t1:result.features.attributes.rent,
t2:result.features.attributes.OBJECTID,
t3:result.features.attributes.ACCT
}), this.rowNode);
}
…..
zoomto: function () {
console.log("zoomto is clicked ");
},
Solved! Go to Solution.
Maria,
"data-dojo-attach-event" is only for a templated dom element that is part of the widgets template, NOT something that dynamically add using domConstruct. In your case you just need to add a "onclick".
it possible that i need to parse the new nodes in table's body? if it is right, i do not know how to do it ...
Maria,
"data-dojo-attach-event" is only for a templated dom element that is part of the widgets template, NOT something that dynamically add using domConstruct. In your case you just need to add a "onclick".
Hi Robert, Thank you, you always help me when i encounter with a error. you are right, i should not use "data-dojo-attach-event". I actually decided to use domConstruct.create for each element in tbody separately and also i used lang.hitch for executing the event's function. i thought this explanations might help a person.
That was a helpful post but when i am adding onclick in the domCreate, it is searching in the index.html and showing an error _customfunction() is not defined in the index page.
I can't use lang.hitch functions for the events cause i have to add the same element multiple times...
Please help me on this.
Cheers,
Naveen
Got the solution.. I created the below code ...
on(query('id'), "click", lang.hitch(this, this.customFunction))