2013-04-06 67 views
0

當寬度爲特定大小時,當前嘗試刪除jScrollPane。這似乎是工作,我可以觸發警報與jscrollPane destroy();和modernizr

if (Modernizr.mq("screen and (max-width:715px)")) { 
     alert('hello world');   
    } 

而且我可以點擊功能

$('.st-accordion a').click(function() { 
     var element = $('.hs-content').jScrollPane({}); 
     var api = element.data('jsp'); 
     api.destroy(); 
}); 

刪除JScrollPane的,但不管是什麼原因,我不能觸發的destroy();與modernizr條件

  if (Modernizr.mq("screen and (max-width:715px)")) { 
        var element = $('.hs-content').jScrollPane({}); 
        var api = element.data('jsp'); 
        api.destroy(); 
      } 

任何想法?

回答

0

沒關係,我把它封裝在同一個函數中。清晰的一刻。

  //Scrollpane 
      $(function() 
       { 
        $('.hs-content').jScrollPane({ autoReinitialise: true, hideFocus: true }); 
        $('.hs-menu nav').jScrollPane({ autoReinitialise: true, hideFocus: true }); 
        if (Modernizr.mq("screen and (max-width:715px)")) { 
        var element = $('.hs-content').jScrollPane({}); 
        var api = element.data('jsp'); 
        api.destroy(); 
        } 
      });