I have jsp page having jQuery DataTables which contain more then 20 pages I'm using textbox in datatable td tags which shows datepicker i.e. check-in /check-out date.
On the 1st page its works perfectly but on the other pages datepicker class is not apply. Here is following code which I used.
HTML code
<table id="tableBookingByBooker">
<thead class="btn-default">
<tr>
<th>checkInDate</th>
<th>checkInDate</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input id="checkInDate${data[0]}" />
</td>
<td>
<input id="Text1" />
</td>
</tr>
</tbody>
</table>
JS Code:
$('input[id^=checkInDate]').each(function (index, element) {
var checkOutDate = (new Date($('#checkOutDate' + $(this).attr('id').substring(11)).val()));
checkOutDate.setDate(checkOutDate.getDate() - 1);
$(this).datepicker({
dateFormat: 'mm/dd/yy',
maxDate: checkOutDate,
});
});
$('input[id^=checkOutDate]').each(function (index, element) {
var checkInDate = (new Date($('#checkInDate' + $(this).attr('id').substring(12)).val()));
checkInDate.setDate(checkInDate.getDate() + 1);
$(this).datepicker({
dateFormat: 'mm/dd/yy',
minDate: checkInDate,
});
});
Input box (checkIn/checkout) Datepicker is successfully working in 1st page of datatable but other pages datepicker is not working.
I tried the pagination event and put js code in the function click but it did not work properly