[英]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.