Jquery nice scroll not working

I am using jquery nice scrollbar for div, but when the content of the div grows dynamically, it does not show the scrollbar. Windows's default scroll bar works fine if I delete a good scroll. Can someone help me solve this problem?

HTML

<div id="div-to-scroll"> </div> 

Script

 $(document).ready(function(e) { var nice = $("#div-to-scroll").getNiceScroll(); $("#div-to-scroll").niceScroll(); $("#div-to-scroll").getNiceScroll().resize(); }); 

this is my sample code.

+7
source share
6 answers

Finally, this works for me.

 $("#div-to-scroll").scroll(function(){ $("#div-to-scroll").getNiceScroll().resize(); }); 
+16
source

only works for me

 $("#div-to-scroll").mouseover(function() { $("#div-to-scroll").getNiceScroll().resize(); }); 
+9
source

UPDATE: new feature found

  var setScroll = function(i) { if($(i).length>0) $(i).niceScroll().updateScrollBar(); } 

Call this function to update niceScroll

 setScroll(".classWithNiceScroll"); 
+2
source

Some possible reasons:
1- You may have forgotten to indicate your div height. correct your div height.
2- also if your div is a float in width also correct this width.
Remember that your DIV STYLE should have: overflow-y: hidden;
UPDATE
try using the resize () function each time you scroll down:

 $("div-to-scroll").slideDown(function(){ $("div-to-scroll").getNiceScroll().resize(); }); 
+1
source
 $("html").mouseover(function() { $("html").getNiceScroll().resize(); }); 

To get the scroll bar on full body

+1
source

Do it:

 // Scroll X Axis $("#mydiv").getNiceScroll()[0].doScrollLeft(x, duration); // Scroll Y Axis - $("#mydiv").getNiceScroll()[0].doScrollTop(y, duration); 

or:

 // Scroll X Axis $("#mydiv").getNiceScroll(0).doScrollLeft(x, duration); // Scroll Y Axis - $("#mydiv").getNiceScroll(0).doScrollTop(y, duration); 

Note [0] after getNiceScroll()

+1
source

All Articles