Orbit/app/assets/Archive/javascripts/inc/ploy_input_field.js

37 lines
1.9 KiB
JavaScript
Raw Normal View History

2012-11-15 09:23:39 +00:00
// var $CloneTarget ;
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());
class_to_be_removed = $(this).parents(".controls").prev(".multipleInput").attr("ext_class")
2012-11-15 09:23:39 +00:00
// $(this).parents(".controls").prev(".multipleInput").children('.controls:last input').val("");
$(this).parents(".controls").prev(".multipleInput").children('.controls:last').find('input').val('')
$(this).parents(".controls").prev(".multipleInput").children('.controls:last').find('.tab-pane').removeClass(class_to_be_removed).addClass("NewInput_"+$modalNumber)
2012-11-15 09:23:39 +00:00
btn = $(this).parents(".controls").prev(".multipleInput").children('.controls:last').find(".nav.nav-pills li")
$.each(btn,function(i,value){
old_link = $(this).children("a").attr("href");
$(this).children("a").attr("href",".NewInput_"+$modalNumber);
2012-11-15 09:23:39 +00:00
});
2012-11-12 02:41:41 +00:00
removeInput();
checkMultipleInput();
return false;
})
});