Created
June 6, 2012 13:46
-
-
Save MauMaGau/2881941 to your computer and use it in GitHub Desktop.
JS/JQUERY: multi-input
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
<script> | |
// Multi-input | |
$('.input-multi-add').click(function(){ | |
var list = $(this).siblings('.input-multi'); | |
var template = list.find('.template'); | |
list.append(template | |
.clone() | |
.removeClass('template hidden') | |
.removeAttr('disabled') | |
.after("<a class="multi-input-remove">Remove</a>") | |
); | |
return false; | |
}) | |
$('.input-multi input:not(.template) ').after("<a class="multi-input-remove">Remove</a>"); | |
$('.multi-input-remove').live('click',function(){ | |
$(this).prev('input').remove(); | |
$(this).remove(); | |
return false; | |
}) | |
</script> | |
<ul class='input-multi'> | |
<label for="client_list">Client List</label> | |
<input type="text" name="profile[client_list][]" value="client1" id="client_list" maxlength="255" size="50" class="normal" /> | |
<input type="text" name="profile[client_list][]" value="" id="client_list" maxlength="255" size="50" class="normal template hidden" disabled="disabled" /> | |
</ul> | |
<a href='#' class='input-multi-add'>add</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment