i using ajax call php return string of dates user available, make dynamic.
i returning string jquery :
['7-15-2013','7-16-2013','7-17-2013','7-18-2013','7-19-2013','7-20-2013','7-21-2013','7-22-2013']
however when initialise datepicker, string of dates not load.
i not sure why, suspect success function after ajax call.
my jquery code looks :
$('.vendor_id').change(function() { var vendor_id = $('option:selected', this).attr('title'); var url = "/admin/po/get_user_dates/" + vendor_id; $.ajax({ type : "post", url : url, success: function(unavaildates) { var disableddays = unavaildates; function disableallthesedays(date) { var m = date.getmonth(), d = date.getdate(), y = date.getfullyear(); (i = 0; < disableddays.length; i++) { if($.inarray((m+1) + '-' + d + '-' + y,disableddays) != -1) { return [false]; } } return [true]; } $('.booking-date').datepicker( { beforeshowday: disableallthesedays, numberofmonths: 2, dateformat: 'dd, d mm, yy', showbuttonpanel: true } ) } }) })
hope call me on this.
quick update.. on assigning disableddays ['7-15-2013','7-16-2013','7-17-2013','7-18-2013','7-19-2013','7-20-2013','7-21-2013','7-22-2013'] datepicker works...?
thanks in advance.
because retrieving string , not array server.
i suggest return string without square brakets "'7-15-2013','7-16-2013','7-17-2013','7-18-2013','7-19-2013','7-20-2013','7-21-2013','7-22-2013'"
server , create array :
var unavaildates = "'7-15-2013','7-16-2013','7-17-2013','7-18-2013','7-19-2013','7-20-2013','7-21-2013','7-22-2013'" var disableddays = unavaildates.split(',');
Comments
Post a Comment