html - 关于mCustomScrollbar自定义滚动条异步加载数据滚动条无效的问题
本文介绍了html - 关于mCustomScrollbar自定义滚动条异步加载数据滚动条无效的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
有人用过这个滚动条插件没:mCustomScrollbar;
在我进行异步加载的过程中,回调函数中的滚动条update无效:
$.ajax({
type: "post",
url: urlStr,
dataType: 'html',
success: function(data) {
$(".main_body_con").html(data);
console.log(1);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert('访问网络失败!' + errorThrown+urlStr);
},
complete: function(){
console.log($(".main_body_con").html());
console.log(2);
$(".main_body_con").mCustomScrollbar("update");
}
});
官方文档里面说使用ajax的回调函数,调用mCustomScrollbar("update"),可以重新加载滚动条,可是我添加了无效。求高手解答。
解决方案
$.ajax({
type: "post",
url: urlStr,
beforeSend: function() {
$(".main_body_con").mCustomScrollbar("destroy"); //Destroy
},
dataType: 'html',
success: function(data) {
$(".main_body_con").html(data);
console.log(1);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert('访问网络失败!' + errorThrown+urlStr);
},
complete: function(){
console.log($(".main_body_con").html());
console.log(2);
$(".main_body_con").mCustomScrollbar({
mouseWheel:true,
theme:"dark-thick",
scrollButtons:{
enable:true
}
});
}
});
这篇关于html - 关于mCustomScrollbar自定义滚动条异步加载数据滚动条无效的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文