jQuery niceScroll Not Working Along w/ .load()

jQuery niceScroll Not Working Along w/ .load()

本文关键字:load Along niceScroll Not Working jQuery      更新时间:2023-09-26

我正在div中实现jQuery插件。它工作得很好,除了当我向使用niceSoll的标签添加.load()函数时,没有滚动功能。但是,如果我删除了niceSoll,那么原生滚动程序就可以正常工作。。。?

这是针对一个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",
                });
            })

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",
                    });
                }
            });