Datepicker Doesn't Refresh Data
Alerts and Firebug shows that everything is working perfectly but datepicker calendar doesn't refresh. What I am trying to do is: Bring employees available dates whenever employe combobox selection changed. I believe it is synchronization problem but couldn't find a solution ? Any help is highly appreciated.
Below is the code:
$(document).ready(function(){
$("#employecombo").change( function() {
$.ajax({
type: "POST",
data: "id=" + $(this).val(),
url: "...php",
dataType: "json",
success: function(data){
var disabledDays = data;
//alert(disabledDays.length);
$('#datepicker').datepicker({
dateFormat: 'mm-dd-yy',
beforeShowDay: daysoff
});
function daysoff(date) {
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
for (i = 0; i < disabledDays.length; i++) {
if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) {
return [false];
}
}
return [true];
}
$("#result_calendar").show();
}
});
});
});
</script>