如何在对话框打开时模糊第一个表单输入 [英] How to blur the first form input at the dialog opening
问题描述
我有一个jQuery.dialog显示一个表单。
第一个输入是< input type =textclass =datepicker/>
我初始化这样的datepicker这样的 jQuery('。datepicker')。datepicker()
。
问题是当对话框打开时,它会聚焦第一个输入。所以datepicker也被打开。
对话框的事件打开
是在焦点放在前面运行的。 p>
那么,我如何将第一个焦点模糊到datepicker保持隐藏?
如上所述,这是jQuery UI的已知错误,应该很快修复。直到那时...
这是另一个选项,所以你不必混淆tabindex:
暂时禁用日期戳,直到对话框打开:
dialog.find(。datepicker) .datepicker(disable);
dialog.dialog({
open:function(){$(this).find(。datepicker)。datepicker(enable);},
});
适用于我。
I have a jQuery.dialog who show a form.
The first input is <input type="text" class="datepicker" />
and I init the datepicker like this jQuery('.datepicker').datepicker()
.
The problem is when the dialog is opened, it focus the first input. So the datepicker is also opened.
The dialog's event open
is run before the focus is putting on.
So, how can i blur the first focus to the datepicker stay hidden ?
As mentioned, this is a known bug with jQuery UI and should be fixed relatively soon. Until then...
Here's another option, so you don't have to mess with tabindex:
Disable the datepicker temporarily until the dialog box opens:
dialog.find(".datepicker").datepicker("disable");
dialog.dialog({
"open": function() {$(this).find(".datepicker").datepicker("enable");},
});
Works for me.
这篇关于如何在对话框打开时模糊第一个表单输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!