1

我在我的 DIV 中实现了 jQuery 插件niceScroll。它工作得很好,除非我将 .load() 函数添加到使用niceScroll的标签中,没有滚动工作。但是如果我删除 niceScroll,那么本机滚动条可以正常工作......?

这是针对 webKit 浏览器的。有什么想法还是我在我的代码中是个傻瓜?

$(document).ready(
            function(e) {

                $("#west").load('http://mySite.comregulatory_list.php', '', function(response, status, xhr) {
                    if (status == 'error') {
                        var msg = "Sorry but there was an error: ";
                        $(".content").html(msg + xhr.status + " " + xhr.statusText);
                    }

                });

                $("#west").niceScroll({
                    cursorcolor : "#6699FF",
                    cursorwidth : "2px",
                    grabcursorenabled : "false",
                    preservenativescrolling : "false",
                    cursorborder : "0px",
                    scrollspeed : "20",
                });
            })
4

1 回答 1

1

niceScroll插件几乎肯定会更新#west元素的 HTML 结构,因此您应该针对元素中的特定内容容器或在加载新内容时#west重新初始化插件:niceScroll

            $("#west").load('http://mySite.comregulatory_list.php', '', function(response, status, xhr) {
                if (status == 'error') {
                    var msg = "Sorry but there was an error: ";
                    $(".content").html(msg + xhr.status + " " + xhr.statusText);
                } else {
                    $(this).niceScroll({
                        cursorcolor : "#6699FF",
                        cursorwidth : "2px",
                        grabcursorenabled : "false",
                        preservenativescrolling : "false",
                        cursorborder : "0px",
                        scrollspeed : "20",
                    });
                }

            });
于 2012-03-15T21:00:22.530 回答