jquery - Datepicker is not working on first click of dynamic element -
jquery datepicker not working on first click, while re initiating script dynamically appended input field!!! solutions ?
// datepicker click event function reinitiated dynamically added input field - script $(document).on("click", ".datepicker", function (evt) { $('.datepicker').datetimepicker({ format: 'd/m/y', timepicker: false, }); event.stoppropagation(); });
your logic here not quite right. should initialise datepicker on page load, not on click of element:
$(function() { $('.datepicker').datetimepicker({ format: 'd/m/y', timepicker: false, }); });
if need intialise on dynamic elements, in callback created:
$.ajax({ url: 'foo.php', success: function(data) { $('#bar').html(data).find('.datepicker').datetimepicker({ format: 'd/m/y', timepicker: false, }); } });
Comments
Post a Comment