Search code examples
jquerytimepicker

jquery Timepicker not working after two or more button click


I am using https://timepicker.co/ in one of my projects.

The requirement is to trigger the timepicker on the click of a button. I finally got it working by using the following code where #time is an input element:

$("#time").focus();

The link to the fiddle is: https://jsfiddle.net/6g2c35hw/2/

Everything is working fine except, when I click the button it opens the timepicker and works fine but if I click anywhere outside (timepicker disappears) and click the button again, the timepicker opens but when I select a time, it doesn't update. You can see this in the jsfiddle. In my project when I do the same, even when I click on the scrollbar or the up and arrows to scroll, the timepicker disappears.

Any help in this regard is appreciated.

Thanks!!


Solution

  • Try using open method

    $('#time').timepicker('open')

    JSFiddle