Scrollpane destroy element on hide

112 views Asked by At

I have a bit complicated scenario with jscrollpane, and a problem with the scrolled element disappearing...

I call jscrollpane with this in js root

var $scrollfix = $('.sidebar nav').jScrollPane().data('jsp');

Then have in doc ready

$scrollfix;

And in window resize

$scrollfix.reinitialise();  

And then I need to remove the jscrollpane when the menu (where the scroll is placed) is closed with a button, and then restore the function when it is opened

$(".close").on('click', function(e){
    // Close menu
    // jScrollpane
    $scrollfix.destroy();   
    e.preventDefault();
});

$(".open").on('click', function(e){
    // Open menu
    // jScrollpane
    $scrollfix; 
    e.preventDefault();
});

But, it doesn't work at the second open after close, I believe because the $scrollfix.destroy(); removes completely the jscrollpane. How can I get it back or not remove it completely, just disable it on the closed menu?

0

There are 0 answers