我使用的是来自http://manos.malihu.gr/jquery-custom-content-scroller/的自定义滚动条。
我在一个包含gridview的div上使用它。当在Gridview中添加新行时,如果该行超出大小,则不会显示滚动条。
我还有另一个问题,里面有一个div,我用一个按钮来切换这个div的显示。
我无法更新滚动条
(function($) {
$(window).load(function() {
$("#rightFixed").mCustomScrollbar({
scrollInertia: 150,
autoHideScrollbar: true,
updateOnBrowserResize: true,
updateOnContentResize: true,
theme: "dark-2"
});
});
})(jQuery);
$(function () {
$("#showTax").click(function () {
$("#cartTaxDiv").slideToggle();
$(this).text($(this).text() == 'Show Tax' ? 'Hide Tax' : 'Show Tax');
$('#rightFixed').mCustomScrollbar("update");
});
});滚动条初始化事件在$(window).load中,Button Click在$(document).ready中。
你能帮我吗??
发布于 2013-07-13 13:31:51
我已经想出了解决办法。
对于slideToggle,我们所要做的就是将更新放在一个函数中,并在切换中调用它。当切换完成时,ie调用函数。
function updateScrollbar() {
$('#rightFixed').mCustomScrollbar("update");
}
$("#showTax").click(function () {
$("#cartTaxDiv").slideToggle(updateScrollbar); // Call the update Scrollbar after the sliding is done.
$(this).text($(this).text() == 'Show Tax' ? 'Hide Tax' : 'Show Tax');
})这样Toggle问题就解决了。
接下来是第二个问题- GridView。当GrodView被更新时,scrollbar必须为updated.So,我们必须在每次回发时调用此函数。我在这里没有使用更新面板,所以如果在页面加载中回发,我将调用这个函数。
if (IsPostBack)
{ Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", "updateScrollbar();", true); }因此问题就解决了。
https://stackoverflow.com/questions/17583729
复制相似问题