I am using the XDSoft jQuery datetimepicker
in my app (Ruby on Rails 4 (just for information, not using bootstrap datetimepicker
)).
I was wondering if there is a way to disable/deactivate a specific time at a specific date, for example disable only 17:00 on 12/17/2014?
disabledDates: ['...']
disables a specific date.
I tried disabledDateTimes
and disabledTimes
but they don't work.
Thanks.
Here is one example of how this can be done using the XDSoft DateTimePicker you are asking about.
I have a
specificDates
array which you can use to add dates you want to target.I also have an
hoursToTakeAway
multi dimensional array which corresponds with thespecificDates
array where you can specify the hours to take away.HTML
Javascript
Example Fiddle
Basically I am taking advantage of the
onGenerate
event which happens after each calendar has been rendered. Then I am checking to see if the date matches the specified day and if it does, we iterate through all the time elements and hide the ones specified for the specific date.Updated Fiddle implementing disable.
Fiddle 2
If someone still need solution, i write code to disable ranges of time in jquery-ui-datepicker.
First I need to init ranges, that will be disabled at current date:
Then I need function, to proceed this ranges, detect intersections and create ranges, that will be displayed:
And code in of datetimepicker:
This code is working for me: