trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

Setting hourMin/hourMax by 'option' does not work. #824

Open jimmyfo opened 9 years ago

jimmyfo commented 9 years ago

When creating a date time picker, it works to set the hourMin/max during initializtion. Since I would like to change the hour min/max depending on user behaviour on the same page, I was trying to use the 'option' setter to change the values. It will change the time, but it leaves the time range from 12 to 12.

            $('#AppointmentViewModel_AppointmentDateTime').datetimepicker({
                hourMin: calEvent.start.hour(),
                hourMax: calEvent.end.hour() - 1,
                timeFormat: 'hh:mm TT',
                stepHour: 1,
                stepMinute: 30,
                timeZone: 'UTC',
                start: 8,
            });

Does not work.

            $('#AppointmentViewModel_AppointmentDateTime').datetimepicker('option', 'hourMin', 9);
            $('#AppointmentViewModel_AppointmentDateTime').datetimepicker('option', 'hourMax', 12);

It seems like it sets the time, it just does not restrict the sliders.

As a work around, I use this and just recreate the picker every time.

            $('#AppointmentViewModel_AppointmentDateTime').removeClass("hasDatepicker");

I'm assuming this is an issue, please let me know if not.