1

I've a problem to open the timepicker of pickadate.js I've tried to open it with the code below but it doesn't works for me.

I get an error : "picker.open() is not a function".

this my js code :

$('.timepicker').pickatime({
    default: 'now', // Set default time
    fromnow: 0,       // set default time to * milliseconds from now (using with default = 'now')
    twelvehour: false, // Use AM/PM or 24-hour format
    donetext: 'OK', // text for done-button
    cleartext: 'Clear', // text for clear-button
    canceltext: 'Cancel', // Text for cancel-button
    autoclose: true, // automatic close timepicker
    ampmclickable: false // make AM PM clickable
});

$('#test').click(function () {
    event.stopPropagation();
    event.preventDefault();
    var picker =  $('.timepicker').pickatime('picker');
    picker.open();
});

A weird thing : I tried to open a pickadate object with the same method and it works perfectly ..

Do you have a solution to avoid it ?

thanks for helping

Jerem
  • 126
  • 1
  • 6

2 Answers2

2

Haven't quite figured out why, but for me the following works:
Instead of
picker.open();
do
picker.data('clockpicker').show();

Hope that helps!

numblock
  • 63
  • 5
0

It's too late to answer but it will help others.

    var picker = $('.timepicker').pickatime({
       default: 'now', // Set default time
       fromnow: 0,       // set default time to * milliseconds from now (using with default = 'now')
       twelvehour: false, // Use AM/PM or 24-hour format
       donetext: 'OK', // text for done-button
       cleartext: 'Clear', // text for clear-button
       canceltext: 'Cancel', // Text for cancel-button
       autoclose: true, // automatic close timepicker
       ampmclickable: false // make AM PM clickable
   });

  $('#test').click(function () {
    event.stopPropagation();
    event.preventDefault();
    // var picker =  $('.timepicker').pickatime('picker');
    picker.open();
  });

reference

Amitesh
  • 2,917
  • 2
  • 19
  • 14