I'm going to clone a part of the form that has some actions click
on the event I want to change all events in attributes in TEMPLATE
to 'n _' + id
. I want a summary from the structure of the clone part - this will be a template
or 10. I tried to do something like this but the binding has been lost:
insert = function ({old old = $ ('# template'); Var copy = old.clone (true); Var html = old.html () Change (/ TEMPLATE / g, 'n' + next_ID); Old.html (HTML); Old.attr ('id', 'n' + next_ID); Old.show ('fast'); Old.after (copy); Next_ID ++; }
Is there any way to do this easily without knowing anything about the structure of the copied element?
No you will have to add the handlers again.
If you really want to avoid it, then use event delegation (or) to attach to your event handlers in such a way that they are not associated with specific node objects, but only Appointment of elements, whether it matches a selector, which happens at the time of the incident.
$ (myform) .delegate ('.dosomething', 'click', function () {// click handle on any click. Now there is anything in the form or later has been added); Try to avoid text processing on
(and html ()
/ innerHTML
. It is unreliable. It is iterative over this object It's better to have a name or class you want to change it with attr
.)
Comments
Post a Comment