orbit-basic/app/assets/javascripts/inc/ploy_input_field.js

26 lines
1.1 KiB
JavaScript
Raw Normal View History

2012-11-12 02:41:41 +00:00
function checkMultipleInput() {
$(".multipleInput").each(function() {
$(this).children('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
function removeInput(){
$(".removeInput").click(function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
$(document).ready(function(){
var $modalNumber = 0;
checkMultipleInput();
removeInput();
$(".addinput").click(function (){
$modalNumber+=1;
var $CloneTarget = $(this).parents(".controls").prev(".multipleInput").children('.controls:last');
$(this).parents(".controls").prev(".multipleInput").append($CloneTarget.clone());
$(this).parents(".controls").prev(".multipleInput").children('.controls:last input').val("");
removeInput();
checkMultipleInput();
return false;
})
});