您好我在dojo环境中刷新jquery.datepicker时遇到了问题。
在通过request.post获取json(测试的日期和数量)之后,我将结果json强制转换为数组对象。我叫函数 - “$(”#Hour“)。datepicker(”refresh“);”什么都没发生请参阅下面的代码: -
var arrDatesNTests = [];
function checkavailableDates(mydate)
{
var $return=false;// set all dates disenable
var $returnclass ="unavailable";
$checkdate = $.datepicker.formatDate("yy-mm-dd", mydate);
for(var i = 0; i < arrDatesNTests.length; i++)
{
if(arrDatesNTests[i] == $checkdate)
{
$return = true;// enable specified dates only
$returnclass= "available";
}
}
return [$return,$returnclass];
}
$(function()
{
$("#Date").datepicker
({
dateFormat: "yy-mm-dd",
numberOfMonths: 1,
onSelect: function( selectedDate )
{
// later add function for hourpicker
},
beforeShowDay: checkavailableDates,
});
});
on(selectBatches, 'change', function(valueBatch)
{
window.winBatch = valueBatch;
pause.show();// cause the main container to be on standby
request.post('list_dates.php',
{ data:{nameDB : (window.winDB), nameCard : (window.winCard), selectedBatch :
valueBatch}, handleAs: "json"
}).then
(
/*//result
response ={"msg":[
{"date":"2012-03-26","numTests":"857"},
{"date":"2012-03-27","numTests":"470"},
{"date":"2012-03-28","numTests":"544"},
{"date":"2012-03-29","numTests":"618"}]}
*/
function(response)
{ try
{ if(response.msg)
{
arrDatesNTests = (response.msg);
$("#Hour").datepicker("refresh");
pause.hide();
}
else
{
pause.hide();
var errormsg = (response.errmsg +"\r\n"+ response.errcode);
throw new Error(errormsg);
}
}
catch(e)
{
pause.hide();
errDlg(""+e+"");
}
}
)
});
请指教。 提前谢谢。