inuyaksa / jquery.nicescroll

nicescroll plugin for jquery - scrollbars like iphone/ipad
https://nicescroll.areaaperta.com/
3.6k stars 1.67k forks source link

autohidemode: false on Ajax page #788

Open passariello opened 5 years ago

passariello commented 5 years ago

Hi guys! I am at work to implement niceScroll on a project but I see that when a div is called by Ajax every time the scrollbar was duplicated. This not happen when I use autohidemode: false or other. We need to remove and recreate the scroll if exist.

I have try .remove(); but not work and probably need to be automatic

/***/

function CustoScrollBar(val){ $(val).getNiceScroll().remove(); $(val).niceScroll({ autohidemode: false }); }

THE CALL: CustoScrollBar('#myDiv'); // or .myDiv

passariello commented 5 years ago

PS: I use $("[class*='nicescroll']").remove(); to remove all scroll before my ask but it's a bit rude but work.

LIKE:

$("[class*='nicescroll']").remove();

CustoScrollBar('#myDiv1'); CustoScrollBar('#myDiv2'); CustoScrollBar('#myDiv3'); CustoScrollBar('#myDiv4');

passariello commented 5 years ago

After some test I find a solution using a nested DIV inside another... like:

<div id="mypage"> <div id="mypageAjax"> contents here </div> </div>

If I ask some contents to put on "mypageAjax" and after I call the niceScroll it works well. All divs are position absolute in a relative body position.