Иван Веков
Иван Веков

Reputation: 23

JScrollPane reinitialization

I have jScrollpane on my website, and one problem with it. What do i mean:

  1. there is a big container without 'height' attribute, which is .jScrollPane
  2. Inside it a lot of 's.
  3. I use .hide() some of that 's.
  4. appears empty scrollable space.

Looks like i have to reinitialize scrollpane. So i tried 'api.reinitialise();' on the script after i use 'hide()' and nothing happened. Whats wrong?

$(document).ready(function(){
    $('.all_model').jScrollPane();
});

$("#check_kitchen").click(function(){
    $( '.classic' ).show();
    $( '.modern' ).show();
    $( '.furniture' ).hide();
    $( '.technik' ).hide();
    var pane = $('.scroll-pane')
    pane.jScrollPane(settings);
    var api = pane.data('jsp');
    api.reinitialise();
   return false;
}); 

Upvotes: 2

Views: 6036

Answers (1)

EdenSource
EdenSource

Reputation: 3387

I thing you call your API twice. First Time into the $(document).ready(), and the seconde time into your click event. And both are not targetting the same element (.all_model or .scroll-pane).

If your container is .scroll-pane, this should work :

$(document).ready(function(){
    $('.scroll-pane').jScrollPane();
});

$("#check_kitchen").click(function(){
    $( '.classic' ).show();
    $( '.modern' ).show();
    $( '.furniture' ).hide();
    $( '.technik' ).hide();
    var api = $('.scroll-pane').data('jsp');
    api.reinitialise();
   return false;
}); 

Or if your container is .all_model, this should work :

$(document).ready(function(){
    $('.all_model').jScrollPane();
});

$("#check_kitchen").click(function(){
    $( '.classic' ).show();
    $( '.modern' ).show();
    $( '.furniture' ).hide();
    $( '.technik' ).hide();
    var api = $('.all_model').data('jsp');
    api.reinitialise();
   return false;
}); 

Waiting your feedback.

Upvotes: 2

Related Questions