按下取消后,jquery 对话框上的 jquery datepicker 将不会显示
我已经在 jquery 的对话框上成功创建了一个 jquery 日期选择器,该对话框是通过 load()
函数加载的。
我能够通过覆盖对话框的打开事件来实现它:
open: function (event, ui) {
if ($('input.date-picker').length > 0) {
$('input.date-picker').datepicker({
showOn: "button",
buttonImage: "/Content/images/calendar.gif",
buttonImageOnly: true
});
$('input.date-picker').datepicker("refresh");
}
},
按下图像按钮后,日期选择器成功显示。但我注意到一些奇怪的事情,当我打开对话框,单击“取消”然后再次打开对话框并单击日历图像按钮时,日期选择器不会显示。
可能有帮助,我还覆盖了对话框的关闭事件:
close: function (event, ui) {
$('input.date-picker').datepicker("destroy");
$(this).dialog("destroy");
}
谢谢
I've successfully created a jquery datepicker on jquery's dialog box that was loaded via load()
function.
I was able to achieve it by overriding dialog box's open event:
open: function (event, ui) {
if ($('input.date-picker').length > 0) {
$('input.date-picker').datepicker({
showOn: "button",
buttonImage: "/Content/images/calendar.gif",
buttonImageOnly: true
});
$('input.date-picker').datepicker("refresh");
}
},
The datepicker successfully show after I press the image button. But I noticed something strange, when I open the dialog, click cancel then open the dialog again and click the calendar image button, the datepicker won't show.
Might help, I've also overriden dialog's close event:
close: function (event, ui) {
$('input.date-picker').datepicker("destroy");
$(this).dialog("destroy");
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 close 函数中,您尝试销毁输入上的日期选择器,其中类为
date-picker
但在上次调用 datepicker 创建之后,输入的类已更改为hasDatepicker
所以尝试使用编辑:
日期选择器应该实现此
close
方法:In the close function you try to destroy datepicker on input where class is
date-picker
but after previous call to datepicker creation the class of the input has changed tohasDatepicker
so try to useEdit :
The datepicker should implement this
close
method :对我有用的是 -
在对话框内,如果我有多个带有类
datepicker
的输入,那么基本上,在初始化
datepicker
之前删除类hasDatepicker
> 再次。我使用的是 jquery.ui.datepicker 的版本 1.8.18
What worked for me was -
Inside the dialog, if I have multiple inputs with class
datepicker
, thenBasically, to remove the class
hasDatepicker
before initializingdatepicker
again.I was on version 1.8.18 of jquery.ui.datepicker