4

我正在使用来自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.

你能帮助我吗 ??

4

1 回答 1

3

我已经想出了解决方案。

对于slideToggle,我们所要做的就是将Update 放在一个函数中并在toggle 中调用它。即切换完成时调用该函数。

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 更新时,滚动条也必须更新。为此,我们必须在每次回发时调用此函数。我在这里没有使用更新面板,所以如果在页面加载中回发,我会调用这个函数。

if (IsPostBack)
{ Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", "updateScrollbar();", true); }

因此问题解决了。

于 2013-07-13T05:31:50.817 回答