简体   繁体   中英

jQuery custom content scroller after ajax call

I found here a lot of questions on this matter but small number of answers. Some of the answers were advanced:{ updateOnContentResize: true } , and I tried it, it didn't work. Also, one of the answers were reinitializing .mCustomScroll function on ajax success but it didn't work for me at all. Is there general solution for this or I should try some other customizable scroll libraries?

To update the content on elements that already have custom scrollbar(s), you need to add/append the new content inside the .mCSB_container element (instead directly to the element you called mCustomScrollbar function). Example:

//scrollbar initialization 
$(".content").mCustomScrollbar();

//at some point later on (within another script, function, ajax call etc.)
$(".content .mCSB_container").append("new content...");
//or targeting a specific .mCSB_container element (usefull with nested scrollbars)
$("#mCSB_1_container").append("new content...");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM