Methods
Available methods on TimepickerUI instance
create()
Initialize the timepicker. Must be called before using other methods.
const picker = new TimepickerUI(input);picker.create();
open(callback?)
Open the timepicker modal programmatically.
picker.open();picker.open(() => {console.log('Picker opened');});
close(updateInput?, callback?)
Close the timepicker modal.
picker.close();picker.close(true)(() => {console.log('Picker closed with update');});
getValue()
Get current selected time value.
const value = picker.getValue();{hour: '10',minutes: '30',type: 'AM',time: '10:30 AM'}
setValue(time, updateInput?)
Set time value programmatically.
picker.setValue('10:30 AM');picker.setValue('15:45', false);
update(options, callback?)
Update picker options dynamically.
picker.update({options: {theme: 'dark',clockType: '24h'},create: true}, () => {console.log('Updated');});
destroy(options?)
Destroy the picker instance and clean up.
picker.destroy();picker.destroy({keepInputValue: true,callback: () => console.log('Destroyed')});
getElement()
Get the root wrapper element.
const wrapper = picker.getElement();
Static Methods
TimepickerUI.getById(id)
const picker = new TimepickerUI(input, { id: 'my-picker' });picker.create();const instance = TimepickerUI.getById('my-picker');
TimepickerUI.getAllInstances()
const allPickers = TimepickerUI.getAllInstances();console.log(allPickers.length);
TimepickerUI.destroyAll()
TimepickerUI.destroyAll();
TimepickerUI.isAvailable(selector)
if (TimepickerUI.isAvailable('#timepicker')) {console.log('Element exists in DOM');}