Javascript jqueryui.widgets在隐藏子对象时重置其滚动位置
我在最近的项目中大量使用jqueryui。不幸的是,由于jQueryUI小部件在包含带有滚动条的元素时表现出一些非常古怪的行为,我遇到了一个大麻烦Javascript jqueryui.widgets在隐藏子对象时重置其滚动位置,javascript,jquery,debugging,jquery-ui,Javascript,Jquery,Debugging,Jquery Ui,我在最近的项目中大量使用jqueryui。不幸的是,由于jQueryUI小部件在包含带有滚动条的元素时表现出一些非常古怪的行为,我遇到了一个大麻烦 在其中一个.Scroll container元素中向下滚动 单击手风琴标题 单击旧标题-注意元素已自动滚动到顶部 有没有办法防止这种情况发生?它与我的一个利用jQuery滚动的主要插件发生了冲突。我完全不知道在这里该做什么 也许这是一个值得在jQuery UI开发论坛中提及的bug 编辑 到目前为止,该错误已在 Chrome-8.0.552.23
.Scroll container
元素中向下滚动- Chrome-
在OSX上8.0.552.231
10.6.5
- Safari—
在OSX上5.0.3
(有意义)10.6.5
- FF-
在OSX上3.6.12
10.6.5
- FF-
在OSX上3.6.12
10.6.5
我也有同样的问题。我提出的一个解决方法是在创建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);