Skip to content

Instantly share code, notes, and snippets.

@diago
Created January 14, 2010 14:03
Show Gist options
  • Save diago/277179 to your computer and use it in GitHub Desktop.
Save diago/277179 to your computer and use it in GitHub Desktop.
Element.addMethods('FORM', {
clone: function(form, id){
// if no id was passed use native clone
if( ! Object.isString(id) ) return Element.clone(form, id);
var form = Element.clone(form, true);
form.writeAttribute('id', id);
// change elements with id attr
var origId, idElements = form.select('[id]');
idElements.each(function(elem){
origId = elem.identify();
elem.writeAttribute('id', id+'_'+origId);
});
return form;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment