jQuery Dialog moveToTop问题 [英] jQuery Dialog moveToTop Issue
问题描述
jQuery UI v1.10似乎在页面上堆叠多个对话框时出现问题,当单击任何对话框时,它会刷新所有打开的对话框。
jQuery UI v1.10 seems to have an issue with stacking multiple dialogs on a page where it will refresh all open dialogs when any dialog is clicked.
以下是一些小提琴。使用相同的代码:
Here are some fiddles. Using the same code:
HTML
<div id="div1" class='d' data-isrc='http://www.slashdot.org'>
</div>
<div id="div2" class='d' data-isrc='http://www.cnn.com'>
</div>
JS
var opts = {
height: 200,
width: 300,
autoOpen: true,
open: function(){
var src = $(this).data("isrc"),
$iframe = $("<iframe seamless='seamless' src='" + src + "'>");
console.log(src);
$(this).append($iframe);
}
};
$("#div1").dialog(opts);
$("#div2").dialog(opts);
这个小提琴是使用jQuery 1.9.1和jQueryUI 1.9.2,并且表现我需要的方式: http://jsfiddle.net/REmJb/
This fiddle is using jQuery 1.9.1 and jQueryUI 1.9.2, and behaves how I need it: http://jsfiddle.net/REmJb/
这个小提琴使用jQuery 2.0.2和jQueryUI 1.10.3,并显示问题: http://jsfiddle.net/ UBV4v /
This fiddle is using jQuery 2.0.2 and jQueryUI 1.10.3, and shows the problem: http://jsfiddle.net/UBV4v/
如何在新的jQuery框架上使上述链接顺利运行[无需刷新]?
How can I make the above link work smoothly [without refreshing] on the newer jQuery framework?
ETA:
看来这会被追溯到 insertBefore()
方法的新方法。引用文档:
ETA:
It seems this gets tracked down to a new approach on the insertBefore()
method. Quoting the documentation:
在jQuery 1.9 之前,附加到单元素的情况并没有创建一个
的新集合,而是返回了创建它的原始集合难以
在与未知
元素数一起使用时可靠地使用.end()方法。
Before jQuery 1.9, the append-to-single-element case did not create a new set, but instead returned the original set which made it difficult to use the .end() method reliably when being used with an unknown number of elements.
...但问题不存在于v1.9所以也许不存在。
... but the issue is not present for v1.9 so perhaps not.
推荐答案
这是我添加到我的用于禁用此行为的脚本。
This is what I added to my scripts to disable this behaviour.
jQuery.ui.dialog.prototype._moveToTop = function(event, silent) {
return true;
};
这篇关于jQuery Dialog moveToTop问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!