2013-04-06 42 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(); 
        } 
      });