简体   繁体   English

ajax调用后的jQuery自定义内容滚动条

[英]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. 一些答案是advanced:{ updateOnContentResize: true } ,但我尝试了一下,但是没有用。 Also, one of the answers were reinitializing .mCustomScroll function on ajax success but it didn't work for me at all. 另外,答案之一是在ajax成功时重新初始化.mCustomScroll函数,但对我来说根本不起作用。 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). 要更新已经具有自定义滚动条的元素上的内容,需要在.mCSB_container元素内(而不是直接添加到您称为mCustomScrollbar函数的元素内)添加/附加新内容。 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...");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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