tags:

views:

46

answers:

1

Is there something similar to jQuery's live()-method in dojo? I have some content that's being loaded with ajax, and need that content to get the same event connections.

dojo.query(".allTheseElements").connect("onclick", function() { /***/ }

And then have the dynamically loaded content fire on this too.

+2  A: 

The dojo.behavior module can help you.

dojo.behavior.add({
    ".allTheseElements" : {
        "onclick" : function() {}
    }
});

Then after the DOM content has been changed, e.g. in the handler of you ajax requests, just call dojo.behavior.apply(). Dojo will apply this behavior to the newly added content incrementally.

Alex Cheng