[英]jQuery UI Datepicker disabling at AJAX Call
我嘗試在觸發onChangeMonthYear
回調函數時使用.datepicker('disable')
方法禁用嵌入式.datepicker('disable')
。
此函數進行AJAX調用(以獲取日期),並在成功后啟用日期選擇器。
不幸的是.datepicker('disable')
從未發生...
顯然,在深入研究Firebug之后,將調用內部的_disableDatepicker
,但是從未找到類hasDatePicker
,因此該函數會提前返回。
我已經將回調函數封裝在一個全局對象中,但這似乎並不影響代碼的行為。
onChangeMonthYear
具有第三個參數inst
,它應該引用datepicker元素。 因此,我應該通過$(inst)
調用來訪問它。
您可以在http://jsbin.com/ahano4/6/edit上找到完整的代碼
這是您的getEventsForDate
函數,其中刪除了一些代碼。
this.getEventsForDate = function(year, month, inst) {
...
$(inst).datepicker('disable');
...
};
這是在加載DOM之后運行的代碼
$(function() {
var date = new Date();
Calendar.getEventsForDate(date.getFullYear(), date.getMonth()+1, {});
...
});
您.datepicker()
一個空對象{}
作為第三個參數傳遞給該函數,然后在其上調用.datepicker()
函數。 顯然,這將無濟於事。
您是否不需要通過要影響的實際元素來調用啟用/禁用?
$(inst).datepicker('disable');//generic and not referring to anything in the DOM
should be
$('#calendar').datepicker('disable');//referring to the datepicker object in the DIV with the ID 'calendar'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.