2012-03-15 163 views
1

我在我的DIV中实现了jQuery插件niceScroll。除了当我为使用niceScroll的标签添加一个.load()函数时,它的效果非常好,没有滚动功能。但是,如果我删除niceScroll,那么本机滚动工作正常......?jQuery niceScroll不能沿w/.load()工作

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

回答

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

      }); 
+0

美丽! Thnx,那是做的。 – CelticParser 2012-03-15 21:06:02

+0

@Andaero欢迎您。如果这解决了您的问题,您可以将我的答案标记为已接受(答案分数旁边的复选标记)。 – Jasper 2012-03-15 21:33:34

+0

我做到了。这个系统让我等了8分钟b4它可以让我这么做。我忘了回到现在。大声笑 – CelticParser 2012-03-16 00:08:57