Reputation: 2214
Example to demonstrate the issue can be found here:
As you can see only the first "Add" button triggers an event. The dynamically generated button does not. This is understandable as on page load these elements have not been created.
So what do I need to change to enable dynamically generated elements to also be registered to an event?
Thanks for looking.
Upvotes: 0
Views: 1085
Reputation: 5377
What about using Element.cloneEvents?
Check this sample: http://jsfiddle.net/Byyu2/5/
It looks kind of ugly, because you can't call cloneEvents() directly on the new row (cloneEvents() does not work recursivly), but it works :-)
Upvotes: 1
Reputation: 9487
The answer mentioned is quite old. If you can, upgrade to MooTools 1.3 instead of 1.2. In MooTools More, you will find the Element.Delegation package. The package handles delegation for all MooTools native events, except focus, blur, mouseenter and mouseleave.
You will find an updated JS Fiddle here: http://jsfiddle.net/Byyu2/1/
Upvotes: 3
Reputation: 101614
An answer on implementing .live (from jQuery) in mootools may be of some use.
Upvotes: 2