Sanjay Rabari
Sanjay Rabari

Reputation: 2081

when creating dynamic content using jquery ajax, scrollbar not appearing

I have some jquery report in which I am creating some dynamic html content (nested divs,span,label) using json. Its using jquery,mCustomScrollbar,commons,jqueryui.

I have one <div>...//some static code </div> in this case everything works fine.

but when I create some code between this <div> // dynamic code using ajax </div>. Its scrollbar not appearing.

but If I minimize,maximize browser window or 'firebug' the scrollbar appearing.

Is it because of dynamice css style generating? I am new to jquery css help

Upvotes: 2

Views: 3543

Answers (2)

Shady Mohamed Sherif
Shady Mohamed Sherif

Reputation: 15759

I have the same problem and I solved it with a work around by using destroy method which is also provided by mCustomScrollbar

when I add the new content to the selector I destroy the mCustomScrollbar

$(selector).mCustomScrollbar("destroy");

then I rebuild it again; you can check destroy and rebuild in this demo

http://manos.malihu.gr/repository/custom-scrollbar/demo/examples/disable_destroy_example.html

BTW update method didn't work with me because as it's mentioned that updateOnContentResize by default is true which calls update method, I really don't know what is problem.

Upvotes: 0

Gabriele Petrioli
Gabriele Petrioli

Reputation: 195992

If the scrollbars you refer to are from the mCustomScrollbar plugin you will need to use its update method once the ajax content is inserted in the DOM.

$(selector).mCustomScrollbar("update");

See the docs at http://manos.malihu.gr/jquery-custom-content-scroller/#methods-section

Upvotes: 2

Related Questions