Reputation: 1427
What I'm trying to archive is cloning my "box" and have a clone one without the values. So the inputs should be empty. I've got this fiddle, with only the function and html. Hope is clear and you guys can help me.
http://jsfiddle.net/XeELs/117/
addAddress: function() {
var cloneCount = 0;
$copy = $("#scroll .first").first().clone().attr("id", "to-add-first_Clone" + cloneCount).addClass('cloned'); //add a new class cloned to the cloned outerDivs
$(".clone", "#to-add-first_Clone" + cloneCount).attr("id", "clone_Clone" + cloneCount);
cloneCount++;
//check breakpoints
var $last_bp = $('#scroll .wrap .breakpoint').last();
var $first = $(".first", $last_bp).length;
if ($first > 2) {
//move this into a new breakpoint
$('#scroll .wrap').append('<div class="breakpoint"/>');
$last_bp = $('#scroll .wrap .breakpoint').last();
}
$last_bp.append($copy);
this.drawNavigation();
},
Upvotes: 3
Views: 6343
Reputation: 7863
I think this is the gist of what you are trying to do.
http://jsfiddle.net/XeELs/132/
The newly cloned box will have empty input values. The delete address links show up intelligently and I added the logic to create new "unique" ids.
Upvotes: 6