I am about to clone a part of form which has some actions bound to click
events. I want to change all occurences of word TEMPLATE
in attributes to 'n_'+ID
. I want to abstract from structure of cloned part - It would be one TEMPLATE
or 10.
I tried to something like this but the bindings are lost:
insert = function(){
var old = $('#TEMPLATE');
var copy = old.clone(true);
var html = old.html().replace(/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 it easily without knowing anything about the structure of the copied element.