每当我在下面的插入超链接文本输入中输入内容时,所有单词都将以textarea
作为它的后面。确定和取消按钮工作正常,但我无法专注于文本输入。jQuery UI聚焦窃取
我们使用jQuery UI 1.10.1。它与以前版本的jQuery 1.8.x很好地协作。
我检查代码的jQuery的背后,它有以下几种方法打开一个模式对话框时调用:
_focusTabbable: function() {
// Set focus to the first match:
// 1. First element inside the dialog matching [autofocus]
// 2. Tabbable element inside the content element
// 3. Tabbable element inside the buttonpane
// 4. The close button
// 5. The dialog itself
var hasFocus = this.element.find("[autofocus]");
if (!hasFocus.length) {
hasFocus = this.element.find(":tabbable");
}
if (!hasFocus.length) {
hasFocus = this.uiDialogButtonPane.find(":tabbable");
}
if (!hasFocus.length) {
hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
}
if (!hasFocus.length) {
hasFocus = this.uiDialog;
}
hasFocus.eq(0).focus();
},
_keepFocus: function (event) {
function checkFocus() {
var activeElement = this.document[0].activeElement,
isActive = this.uiDialog[0] === activeElement ||
$.contains(this.uiDialog[0], activeElement);
if (!isActive) {
this._focusTabbable();
}
}
event.preventDefault();
checkFocus.call(this);
// support: IE
// IE <= 8 doesn't prevent moving focus even with event.preventDefault()
// so we check again later
this._delay(checkFocus);
},
是从这里取:http://code.jquery.com/ui/1.10.1/jquery-ui.js
有趣...我有一个与垂直内容的滚动对话框中的锚标签类似的问题。如果向下滚动并单击对话框中的任意位置,焦点将滚动回到对话框中最上面的锚点标记。我已经将它追溯到你所引用的代码,但我不愿意评论那些代码......我也不应该......我觉得解绑是肮脏的。 – incutonez
这是jQuery UI中的一个错误:http://bugs.jqueryui.com/ticket/9101。应该在下一个版本中修复。 – Noyo
该错误在jQuery UI 1.11.0中修复。这是我正在运行的版本,但我仍然观察到这个问题。 –