Reputation: 5701
In dojo, is there a way to get notified when an element of certain class (or contain certain text) has been created?
There is an almost exactly the same question asked in here for jQuery. But I'd like to know if there is a similar solution for dojo. Thank you!
Upvotes: 7
Views: 1295
Reputation: 6828
For dojo 1.7, based on the JQuery answer, I would do :
require(["dojo/on", "dojo/_base/array"], function(on, array){
on(dojo.doc, "DOMNodeInserted", function(evt){
var classes = dojo.attr(evt.target, "class").split(" ");
if (array.indexOf(classes, "myclass") > -1) {
console.debug("Inserted node with class myclass", evt.target);
}
});
});
Upvotes: 6