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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -