У меня есть таблица, где у меня есть два выбора даты и возможность добавить новую строку. Проблема заключается в том, что когда я добавляю новую строку, функция datepicker не работает.Datepicker не работает при добавлении строки
Я создал https://jsfiddle.net/3uhkeq1h/2/
<script>
$(document).ready(function() {
$('.txtDate22').datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'MM yy',
showButtonPanel: true,
onClose: function() {
var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
$(this).datepicker('refresh');
},
beforeShow: function() {
if ((selDate = $(this).val()).length > 0) {
iYear = selDate.substring(selDate.length - 4, selDate.length);
iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 1));
$(this).datepicker('setDate', new Date(iYear, iMonth, 1));
}
}
});
$(".txtDate22").focus(function() {
$(".ui-datepicker-calendar").hide();
$("#ui-datepicker-div").position({
my: "center top",
at: "center bottom",
of: $(this)
});
});
$(".txtDate22").blur(function() {
$(".ui-datepicker-calendar").hide();
});
});
</script>
Умм не уверен, что вы сделали изменения? –
@ anatp_123 проверить обновленный jsfiddle –
umm, если вы имеете в виду этот https://jsfiddle.net/3uhkeq1h/2/? –