Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to refresh datepicker? function .datePickerMultiMonth()

Really like datepicker. Thanks a lot for this great library!

I have got one question for you based in this example (inline datepicker):

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerMultiMonth5.html

I added a "renderCallback" function to disable week days based on checkboxes... (e.g. when saturday-checkbox is checked disable all saturdays shown).

This works perfectly fine when initializing the calender with datePickerMultiMonth().

But how can I refresh the inline calender when one of the checkboxes is changed (e.g. deselect monday-checkbox)?

As-is: when I select / deselect a checkbox the datepicker remains unchanged.. only after manually changing to the next month it updates and disables e.g. all mondays... this should immediately happen when changing the monday-checkbox.

Do you have any idea how I can refresh the datepicket? Thanks a lot for your help!

Cheers, Markus

like image 491
Markus Avatar asked Dec 14 '22 00:12

Markus


2 Answers

.datepicker( "refresh" )

You can find it on http://jqueryui.com/demos/datepicker/#method-refresh click the "Methods" tab

like image 174
BlondinkaBrain Avatar answered Dec 15 '22 13:12

BlondinkaBrain


Probably the easiest way to solve the problem is to remove the existing calendar and then rerender it. e.g.:

$mm.empty().datePickerMultiMonth({});

However, this has some drawbacks as the state of your date picker isn't maintained (e.g. displayed month, selected dates etc).

So I just made some changes to the plugin and introduced a new method: dpmmRerenderCalendar on the multimonth picker (and the corresponding dpRerenderCalendar on the date picker itself).

You can see an example of it in action here:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerMultiMonth7.html

And can grab the latest plugin code from my site or the googlecode repository.

like image 22
vitch Avatar answered Dec 15 '22 14:12

vitch