jQuery UI v1.10 似乎在页面上堆叠多个对话框时存在问题,当单击任何对话框时,它将刷新所有打开的对话框。
这里有一些 fiddle 。使用相同的代码:
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);
这个 fiddle 使用 jQuery 1.9.1 和 jQueryUI 1.9.2,并且按照我需要的方式运行:http://jsfiddle.net/REmJb/
这个 fiddle 使用 jQuery 2.0.2 和 jQueryUI 1.10.3,并显示问题:http://jsfiddle.net/UBV4v/
如何使上述链接在较新的 jQuery 框架上顺利工作(无需刷新)?
预计到达时间: 看来这可以追溯到 insertBefore() 方法的新方法。引用the documentation :
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 中不存在该问题,所以也许不存在。
最佳答案
这是我添加到脚本中以禁用此行为的内容。
jQuery.ui.dialog.prototype._moveToTop = function(event, silent) {
return true;
};
关于jQuery 对话框 moveToTop 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17799023/