jquery datepicker范围触发事件
我有一个带有起始日期和截止日期的 jquery ui 日期选择器范围,当日期范围更改时如何发送警报?这是我的代码:
$(function() {
var dates = $("#date-from, #date-to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 2,
onSelect: function(selectedDate) {
instance = $(this).data("datepicker"), date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.datepicker("option", "dateFormat", "DD, d MM, yy");
}
});
$('#date-from').datepicker({
onClose: function() {
alert("closed");
}
});
});
但是 onClose:
事件没有被触发。谢谢
I have a jquery ui datepicker range with a from-date and to-date, how do I send an alert when the date range is changed? here's my code:
$(function() {
var dates = $("#date-from, #date-to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 2,
onSelect: function(selectedDate) {
instance = $(this).data("datepicker"), date = $.datepicker.parseDate(
instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
dates.datepicker("option", "dateFormat", "DD, d MM, yy");
}
});
$('#date-from').datepicker({
onClose: function() {
alert("closed");
}
});
});
but the onClose:
event is not fired. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以单独初始化
#date-from
和#date-to
,也可以在组合启动中包含onClose
选项并检查元素ID。以下是第二种方法的示例:请参阅实际操作: http://jsfiddle.net/william/ L9Szd/1/
You can either separately initialise
#date-from
and#date-to
, or include theonClose
option in the combined initiation and check for the element ID. Here is an example for the 2nd approach:See this in action: http://jsfiddle.net/william/L9Szd/1/