7

i was trying to use the follow jquery plugin: http://jscrollpane.kelvinluck.com/dynamic_content.html
but i'm still no success when i try to reinitialize the API

I have a div (id=content) which receives the response from load() method (jquery), after all, I use $('#content).jScrollPane() again to refresh the scrollbar, but no success =\

can any one help me? thanks!

davi
  • 71
  • 1
  • 1
  • 2
  • 1
    funny i have the same problem! I can load the content then execute $('#content).jScrollPane() and that shows the scrollbars. repeating this (on content refresh) makes jScrollPane stop working. I know we have to reinitialize() but haven't figured out how yet. – djeetee Apr 24 '11 at 05:48
  • 1
    here's the answer... i declared 2 globals var _jsp_api; var _$items_list; (you will see the reason in a sec) then on document load i execute these 2 statemenets: _jsp_api = $(".scroll-pane").jScrollPane( whatever jsp options you need ).data('jsp'); _$items_list = _jsp_api.getContentPane(); now every time you need to update the content of the scrollable area u will use _$items_list instead of whatever you were using before and when the content changes you have to execute: _jsp_api.reinitialise(); that's all folks. hope this helps. – djeetee Apr 25 '11 at 19:52

2 Answers2

11

A quick google yields the following from

http://jscrollpane.kelvinluck.com/dynamic_content.html

function refreshNav() {
    var pane = $('YOUR SELECTOR');
    var api = pane.data('jsp');
    api.reinitialise();
}

Works very well......

Delicia Brummitt
  • 2,160
  • 1
  • 20
  • 23
pixelvoid
  • 111
  • 1
  • 3
4

...and if you want to refresh all scroll panes on your site use this:

function refreshPane() {
  var pane = $('YOUR SELECTOR').each(function(){
    var api = $(this).data('jsp');
    api.reinitialise();
  });   
}
Bruno Reis
  • 37,201
  • 11
  • 119
  • 156
swys
  • 41
  • 2