Skip to content

Instantly share code, notes, and snippets.

@ElmahdiMahmoud
Created June 21, 2013 13:10
Show Gist options
  • Save ElmahdiMahmoud/5831032 to your computer and use it in GitHub Desktop.
Save ElmahdiMahmoud/5831032 to your computer and use it in GitHub Desktop.
js: clone
$(".clone").on('click', function(e) {
e.preventDefault();
var $repeatable = $(this).closest('.toclone').find('.repeatable').eq(0).clone();
var $selectAll = $repeatable.find('select').clone();
$repeatable.empty();
$repeatable.append($selectAll).addClass('cloned');
$repeatable.append('<a class="removeCloned" href="#">x</a><div class="clear"></div>');
$(this).before($repeatable).parent().trigger('create');
});
$(document).on('click', '.removeCloned', function() {
$(this).parent().remove();
return false
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment