try to do an async:false request in your changemoth function
2009/6/5 Francesco Bancalà <[email protected]>
>
> Hi.
>
> First I post the code, than I'll explain what should do but it
> doesn't.
>
> var specialDays = [1,2];
>
> function onBeforeShowDay(thedate)
> {
> var theday = thedate.getDate();
> if( $.inArray(theday,specialDays) == -1 ) return [false,""];
> return [true, "specialDate", "tooltip"];
> }
>
> function onOnChangeMonthYear(year, month, inst)
> {
> $.get("http://www.example.org/ajax/get-news/"+year+"/"+month, { },
> function(json) {
>
> // alert(json.specialDays.length); test...ok
> specialDays = json.specialDays;
> $(inst).datepicker("refresh");
>
> },"json");
> }
>
> $(document).ready(function() {
>
> $.datepicker.setDefaults($.extend({showMonthAfterYear: false},
> $.datepicker.regional['it']));
> $("#calendar").datepicker({
> onChangeMonthYear: onOnChangeMonthYear,
> beforeShowDay: onBeforeShowDay
> });
>
> });
>
> What I want to do is that when I change the month of the datepicker,
> an ajax call is fired to get events for that month and returned in a
> json fashion way. In the same way an array with a list of days to be
> highlighted is returned.
>
> What it doesn't work is that since the ajax callback may be fired a
> bit later of the end of onChangeMonthYear, and so the new list of the
> special days is not arrived yet, I need to refresh the datepicker when
> it happens to reflect the new beforeShowDay, and I use:
>
> $(inst).datepicker("refresh");
>
> I found it here, undocumented feature to refresh/redraw the
> datepicker, but id doesn't work, the month changes but the new special
> days are not highlighted.
>
> Any help? Thank you very much.
>
> >
>
--
Gustavo Salome Silva
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---