Search code examples
jquerydatetimepicker

How can i display datetimepicker on an input focus that was create on the fly


I create inputs using .append() method on the fly what I need to do is bring up the datetimepicker when a user click's on the input field.

Here is what I have done so far but it is not working for me

        $('.triggerOnPicker').on('focus', datetimepicker({
            timeFormat: "hh:mm TT",
            changeMonth: true,
            changeYear: true,
            stepMinute: 5,
            beforeShowDay: $.datepicker.noWeekends,
            HourMin: 5,
            HourMax: 17, 
            minDate: 0

        });

How can I fix this code to display the datetimepicker?

Thanks


Solution

  • I got it I had to add datetimepicker code to my $.getJSON();

    $.getJSON(
    
    //handle the request code
    
    
    ).done(function(){
    
        $('.triggerOnPicker').datetimepicker({
            timeFormat: "hh:mm TT",
            changeMonth: true,
            changeYear: true,
            stepMinute: 5,
            beforeShowDay: $.datepicker.noWeekends,
            HourMin: 5,
            HourMax: 17,
                minDate: 0
        });
    
        });