views:

269

answers:

3

Hi Everybody,

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

A: 

After having a bit of a look at the source, it seems you'll have to do something like this:

$.event._dpCache[$('.date-pick')[0]._dpId]._applyRenderCallbacks()

or possibly this:

$.event._dpCache[$('.date-pick')[0]._dpId]._rerenderCalendar()

The $.event._dpCache[$('.date-pick')[0]._dpId] part is used to get the first internal DatePicker object matching the css '.date-pick', which is needed to access the internal _applyRenderCallbacks and _rerenderCalendar functions.

Unfortunately, this does access the internal structure of the plugin, so it is possible it might break when new versions are released, however I couldn't find any publicly accessible way to refresh the calendar.

Tobias Cohen
Nice detective work and good workaround for the lack of public access to the relevant method of the plugin... This would have been the best solution at the time the question was answered. I've just updated the plugin so that the rerender method is publicly available which makes for a more maintainable solution...
vitch
A: 

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.

vitch
A: 

Thanks a lot!! your response time is amazing and the quality of your replies as well! @vitch: thanks, works like charm. cheers, markus

markus
if you liked my answer and it worked for you, please click the checkmark next to it to accept it, thanks
Tobias Cohen