Skip to content

Instantly share code, notes, and snippets.

@da1nonly
Created April 18, 2012 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save da1nonly/2416071 to your computer and use it in GitHub Desktop.
Save da1nonly/2416071 to your computer and use it in GitHub Desktop.
new
jQuery('.repeatable-add').click(function() {
field = jQuery(this).closest('td').find('.custom_repeatable li:last').clone(true);
fieldLocation = jQuery(this).closest('td').find('.custom_repeatable li:last');
jQuery('input', field).val('').attr('name', function(index, name) {
return name.replace(/(\d+)/, function(fullMatch, n) {
return Number(n) + 1;
});
})
field.insertAfter(fieldLocation, jQuery(this).closest('td'))
return false;
});
jQuery('.repeatable-remove').click(function(){
jQuery(this).parent().remove();
return false;
});
jQuery('.custom_repeatable').sortable({
opacity: 0.6,
revert: true,
cursor: 'move',
handle: '.sort'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment