我正在大量使用jQuery UI和我的最新项目。不幸的是,当jQuery UI小部件包含带有滚动条溢出的元素时,由于jQuery UI小部件显示的一些非常糟糕的行为,我遇到了一个主要障碍。
.scroll-container
元素反正有没有阻止这种情况发生?它正在使用jQuery滚动的一个主要插件。对于在这里做什么,我很茫然!
也许这是jQuery UI开发论坛中值得一提的错误......
到目前为止,该错误已经确认 ...
8.0.552.231
在OSX上10.6.5
5.0.3
在OSX上10.6.5
(有意义)3.6.12
在OSX上10.6.5
不存在 ...
3.6.12
在OSX上10.6.5
答案 0 :(得分:1)
我遇到了同样的问题。我想出的一个解决方法是在创建后设置ui对象的id。然后我在隐藏对象之前保存scrollTop()位置。当我再次显示对象时,我只需将scrollTop()设置为保存的值。
// Set the id of the object if you have multiple objects with the same class
if ($("#divScroll").length == 0) { // If the object does not exist with an id
$(".ui-jqgrid-bdiv").each(function () { // Select each object via class
strID = $(this).attr("id");
// If the current object (selected via class) does not have an id, set id
if (strID == undefined || strID == false) {
$(this).attr("id", "divScroll");
}
});
}
// Save the scroll position before hide()
intScrollTop = $("#divScroll").scrollTop();
$("#divScroll").hide();
// Set the scroll position to the saved value after show()
$("#divScroll").show();
$("#divScroll").scrollTop(intScrollTop);
答案 1 :(得分:0)
根据回答我的故障单的jQuery UI dev:
这就是浏览器的工作方式,一旦隐藏元素,它就会失去滚动位置。