Hi,
I would like to use the datepicker with the renderCalendarCallback event and that is working. Only on changing the month there sould be a refresh of the dates that should be enabled/disabled. Also on loading the first timethis data should be collected through ajax. I tried onshow, before show an onChangeMonthYear only they don't seem to exsist. Is there a way to do this?
See my code below. I hope my question is clear.
Boudewijn
<script type="text/javascript" charset="utf-8">
$(function()
{
var resultnew = [];
var d = new Date('7/7/2010');
var actionWisseldagen = [];
$('.date-pick-van').datePicker(
{
startDate:'7/7/2010',
onShow:function(input,inst)
{
getWisseldagen( 7, 2010);
},
onChangeMonthYear:function(year, month, inst)
{
getWisseldagen( month, year);
},
renderCallback:function($td, thisDate, month, year)
{
switch (actionWisseldagen[thisDate])
{
case 0:
$td.addClass('weekend');
$td.addClass('disabled');
break;
case 1:
$td.addClass('weekend');
break;
default:
$td.addClass('disabled');
break;
}
} } ).val(d.asString()).trigger('change');
$('#date-pick-van').bind( 'dpClosed', function(e, selectedDates) { var d = selectedDates[0]; if (d) { d = new Date(d); $('#date-pick-tot').dpSetStartDate(d.addDays(1).asString()); } } );
var d = new Date('7/7/2010'); $('.date-pick-tot').datePicker({startDate:'7/7/2010'}).val(d.asString()).trigger('change'); $('#date-pick-tot').bind( 'dpClosed', function(e, selectedDates) { var d = selectedDates[0]; if (d) { d = new Date(d); $('#date-pick-van').dpSetEndDate(d.addDays(-1).asString()); } } );
});
function getWisseldagen( month, year) { $.ajax({ url: "../includes/subs/ajaxWisseldagen.asp", data: { 'month':month, 'year':year, 'klant':3024, 'objecttype':'A75' }, type: "POST", dataType: "text", success: function(result) { for (i=1;i<=31;i++) { tmpdate= i + "-" + month + "-" + year; resultnew[tmpdate] = result[i]; } actionWisseldagen = actionWisseldagen.concat(resultnew); getWisseldagen( month+1, year); getWisseldagen( month-1, year); } }); }