Created
April 18, 2012 19:48
-
-
Save da1nonly/2416071 to your computer and use it in GitHub Desktop.
new
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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