ユーザーがボタンをクリックしたときに複製するjquery日付ピッカーフィールドがありAdd
ます。画面に後で追加されるフィールドに日付ピッカーを表示したい。現在、日付ピッカーは最初のフィールドと。にのみ表示されていますnot for the added/cloned fields
。
ここで同様のトピックに関する多くの投稿を確認した後、私はこの段階で到達することができました。以下はこれまでの私のコードです。
<div class="repeatingSection">
<a href="#" class="deleteDate" style="display: none;">-Delete</a>
<input type="text" class="dateListValues" style="position: relative; z-index:100000;"
id="dateListValues_1" size="15" />
</div>
<a href="#" class="addDate">+ Add</a>
JS:
// Add a new repeating section
$('.addDate').click(function(){
var currentCount = $('.repeatingSection').length;
var newCount = currentCount+1;
var newID;
var lastRepeatingGroup = $('.repeatingSection').last();
var newSection = lastRepeatingGroup.clone();
newSection.insertAfter(lastRepeatingGroup);
newSection.find("input").each(function (index, input) {
input.id = input.id.replace("_" + currentCount, "_" + newCount);
input.name = input.name.replace("_" + currentCount, "_" + newCount);
input.value = "";
//removing the additional hasDatepicker class
$('#'+input.id).removeClass('hasDatepicker');
});
return false;
});
$('.dateListValues').each(function(){
$(this).datepicker();
});
ありがとう。