jQuery UI datepicker opens automatically within dialog(jQuery UI datepicker 在对话框中自动打开)
问题描述
我有一个在 jQuery 对话框对象中使用的日期选择器.对话框内容的来源是使用 .load()
加载的.在对话框中,我创建了一个脚本,该脚本为文本输入创建了一个日期选择器.
I have a datepicker which is used within the jQuery dialog object. The source of the dialog's content is loaded using .load()
. Within the dialog I created a script which creates a datepicker for the text input.
$("#date").datepicker({ ... });
当我第一次打开对话框时 - 一切正常,但如果我关闭它并再次打开,日期选择器会自动触发(并且没有像 autoOpen:false
这样的选项)有什么方法可以防止这种情况发生吗?或者我做错了什么?
When I open the dialog for the first time - everything is okay, but if I close it and reopen again, the datepicker is triggered automatically (and there's no such an option like autoOpen:false
)
Is there any way of preventing this or what am I doing wrong?
推荐答案
我遇到了这个确切的问题,并且只对 tvanfosson 的技术稍作改动就解决了它.出于某种原因,我不得不手动将点击"事件附加到日期选择器字段,如下所示.
I had this exact problem and solved it with only a slight variation on tvanfosson's technique. For some reason I had to manually attach the "click" event to the datepicker field as below.
$('#dialog').dialog({
open: function(event, ui) {
$(ui).find('#date').datepicker().click(function(){
$(this).datepicker('show');
});
},
close: function(event,ui) {
$(ui).find('#date').datepicker('destroy');
}});
(抱歉——我更愿意将此作为评论发布到 tvanfosson 的帖子,但没有必要的代表.)
(Sorry--I would've preferred to post this as a comment to tvanfosson's post but don't have the requisite rep.)
这篇关于jQuery UI datepicker 在对话框中自动打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery UI datepicker 在对话框中自动打开


基础教程推荐
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01