jQuery UI的日期选择器中的对话框会自动打开 [英] jQuery UI datepicker opens automatically within dialog
问题描述
我是jQuery的对话对象中使用的日期选择器。对话框的内容的来源是使用加载 .load()
。在该对话框我创建了创建日期选择器的文本输入的脚本。
$(#日期」)日期选择器({...});
当我打开的第一次对话 - 一切都没有问题,但如果我关闭并重新打开一遍,日期选择器会自动触发(有像的AutoOpen没有这样的选择:假
)
有没有什么办法了preventing这还是我究竟做错了什么?
我有这个确切的问题,并与tvanfosson的技术,只有轻微的变化就解决了
$('#对话)。对话框({
开放:功能(事件,UI){
$(UI).find('#日期)。日期选择器()。点击(函数(){
$(本).datepicker('秀');
});
},
关闭:功能(事件,UI){
$(UI).find('#日期)日期选择器('消灭')。
}});
(对不起 - 我会一直pferred张贴此作为一个注释tvanfosson的职位$ P $,但不具备必要的REP)
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({ ... });
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?
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');
}});
(Sorry--I would've preferred to post this as a comment to tvanfosson's post but don't have the requisite rep.)
这篇关于jQuery UI的日期选择器中的对话框会自动打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!