I need to delegate an event for newly created elements, I need to bind a handler to their creation event. Something like: onCreate
I do not want to bind the event to the element after creation, accessing 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 any way to do this when closing Google? the goal is to attach the event to the creation and not calling the function to attach it.
Can anyone advise? I am new to Closures.
thanks
closures jquery events delegation google-closure
Galvani
source share