In my development, I came on a strange problem. The following is my jquery code to load 2 datepicker when the page load, those 2 datepickers are disable the dates which are not available, here is the code:
$(document).ready(function () {
$('#textfield1').datepicker( "destroy" );
$('#textfield2').datepicker( "destroy" );
$("#loading2").html('<img src="images/loading.gif"/>');
var dataString = 'a=b';
$.ajax({
type: "GET",
url: "include/getdate.php",
data: dataString,
success: function(data){
$(".tempimg").hide();
$("#textfield1hid").datepicker({
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true,
dateFormat: 'd M yy',
altField: "#textfield1",
altFormat: "yy-mm-dd",
beforeShowDay: reservedDates
});
$("#textfield2hid").datepicker({
showOn: "button",
buttonImage: "/images/calendar.gif",
buttonImageOnly: true,
dateFormat: 'd M yy',
altField: "#textfield2",
altFormat: "yy-mm-dd",
beforeShowDay: reservedDates
});
natDays = data;
function reservedDates(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1
&& date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
return [true, ''];
}
$("#loading2").html('');
}
});
return false;
});
This code is working fine on Firefox and IE7. But when the it shows in IE8, the datepickers are not loading, but the ajax responses are coming from the server. These are my 2 text fields
<input type="text" name="textfield1hid" id="textfield1hid" />
<input type="text" name="textfield2hid" id="textfield2hid" />
This is the response from the server:
[[04,01],[04,01],[04,02],[04,02],[04,03],[04,03]]
After IE8 loaded the page, still the text fields are as shown below
<input name="textfield1hid" disabled="disabled" id="textfield1hid" style="background-color: #a0a0a4;" type="text"/>
the next text field also get the same attributes, and I added them a long time ago and removed them all, other browsers are working fine even IE7 but problem is in IE8
Can anybody give me a help to solve this problem