Richard Rodriguez Richard Rodriguez - 1 month ago 6
Javascript Question

Nanoscroller doesn't create a scroll if the content is inserted after the scroller is initiated

I'm using nanoscroller js to create a scrollable area in a

div
element. The problem is that I'm filling that
div
element with data with ajax (imagine facebook notifications). First there are 0 notifications, no data. Then I fill it with 10. The scrollbar isn't there. When I refresh the page (with 10 notifications now already there), it creates itself, because it knows there is more content than there is room.

How can I make it create the scroller when the data is filled?

Answer

Reinitialize the nanoScroller $("your scrollable").nanoScroller(); after you inserted the content...

like

$("your content div").append("something");
$("your scrollable container").nanoScroller();