Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateCloneCriteria(original, keepValues) {
- var clone = $(original).clone();
- if (keepValues)
- {
- // unfortunately, the jquery library was unreliable for copying all of the children values correctly so we're doing it manually.
- $(clone).find('.form-control').each(function(){
- var cloneObject = this; // keep names straight
- var originalObject = $(original).find('#' + $(cloneObject).attr("id"));
- $(cloneObject).val($(originalObject).val());
- });
- }
- // give it a unique Id
- var maxIdNumber = 0;
- $('.divRow').each(function() {
- var thisIdSplit = $(this).attr("id").split("divRow");
- var thisIdNumber = parseInt(thisIdSplit[1]);
- if (thisIdNumber > maxIdNumber) {
- maxIdNumber = thisIdNumber;
- }
- })
- var newIdNumber = maxIdNumber + 1
- $(clone).attr("id", "divRow" + newIdNumber.toString());
- $(clone).children().first().attr("id", "innerDivRow" + newIdNumber.toString());
- return clone;
- }
Add Comment
Please, Sign In to add comment