I need to delegate event to newly created elements, I need to attach handler to their creation event. Something similar to: onCreate
I do not want to bind the event to the element after the creation by addressing it: jQuery:
$(element).click(function(){});
I would prefer something like
$.on('document','spawn', '.item', function(e) {
if (e.target == this.target) {
alert('element created: '+this);
}
});
Is there a way to do so in google closure? the goal is to attach the event on creating and not calling function to attach it.
Could anyone advice? I am new to Closures.
Thanks