$(window).load(function(){
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
// ajax code
function beauty_of_ceylon() {
$('.content-text').html('<p style="position:absolute;"><img src="images/ajax-loader.gif" /></p>');
$('.content-text').load("packages/beauty-of-ceylon.php");
}
回答
$('.content-text').load("packages/beauty-of-ceylon.php", function() {
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
$content = '<button id="update" onclick="$('#content_1').mCustomScrollbar('update');" style="display:none"></button>';
$('.content-text').append($content);
setTimeout("$('#update').click();",10);
});
它爲我工作:d
Thanx它的工作 – AkilaH
工作,我相信是異步的,這意味着它延續了通話過程中運行該腳本。所以你必須在回調函數中調用mCustomScrollbar,否則內容將不會在那裏。所以試試這個
$('.content-text').load("packages/beauty-of-ceylon.php", function() {
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
});
這是一段時間,所以我猜你已經找到了解決方案。如果沒有,你的代碼是正確的,一點。你做一個.load
後,使用它的回調函數來啓動此命令:
$(selector).mCustomScrollbar("update");
在他們的網站,它說,每當你更新內容,你必須讓mCustomScrollbar重新計算內容的高度,滾動條等調用這個函數
window.load不會被調用,所以mCustomScrollBar不initialized.when頁面加載阿賈克斯文件準備將被觸發。
請嘗試下面的代碼。
$(document).ready(function(){
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
});
簡單地嵌入腳本到JSON/AJAX調用的內容,如:
1.JSON/AJAX後端腳本(的MyScript .vendor,比如Ruby,PHP ...)
var myHTMLContent = '<script>
$(".popover-n-content").mCustomScrollbar({
theme:"dark",
scrollInertia:100
});
</script>
<div>
<-- Manipulate -->
<other_html_tags>
...
</other_html_tags>
</div>';
2.Calling腳本 「myscript.vendor」
$.ajax({
url: "/get/myscript.vendor",
type: "post",
dataType: "html",
success: function (data) {
$('#data').html(data);
}
});
$(document).ready(function(){
(function($){
$(every_selector).on("hover",function(){
$(".your_content_selector").mCustomScrollbar({
theme:"dark-2",
snapAmount:40,
scrollButtons:{enable:true},
keyboard:{scrollAmount:40},
mouseWheel:{deltaFactor:40},
scrollInertia:400
});
});
})(jQuery);
});
嗨我這樣做:)
摧毀它,當阿賈克斯之前發送和清除div.Please支票評論
$(document).ready(function(){
$(".YOUR-CONTENT-DIV").mCustomScrollbar({
theme:"dark",
});
$.ajax({
url: "YOUR AJAX URL",
type: "post",
data: data,
beforeSend: function() {
$(".YOUR-CONTENT-DIV").mCustomScrollbar("destroy"); //Destroy
$('.YOUR-CONTENT-DIV').html('<div class="loading">Loading ...</div>'); //clear html because it will show normal scroll bar
},
success: function(data) {
$('.YOUR-CONTENT-DIV').html(data);
},
complete: function() {
$(".YOUR-CONTENT-DIV").mCustomScrollbar({
theme:"dark",
});
}
});
});
謝謝兄弟! –
非常感謝您的幫助..您拯救了我的一天.... –
- 1. JQuery mCustomScrollbar autoScrollOnFocus
- 2. mCustomScrollbar插件不能用於動態加載的內容
- 3. JQuery的AJAX淡入內容
- 4. jQuery的插入內容(Ajax)
- 5. 加載內容的jQuery AJAX
- 6. JQUERY函數不能使用AJAX內容
- 7. ajax內容不加載在jquery標籤
- 8. jquery,ajax內容不可點擊
- 9. jQuery的Ajax Navigaion內wordpress內容區域
- 10. jquery ajax更改div內容
- 11. 用jQuery/Ajax加載內容
- 12. jquery追加ajax內容後
- 13. jquery Ajax內容未加載
- 14. ajax和jquery加載內容
- 15. 關閉AJAX內容與jQuery
- 16. jquery ajax內容未加載
- 17. Jquery Custom ScrollBar(Malihu - mCustomScrollBar)不起作用
- 18. jquery modal with ajax內容加載onclick並不是全部一次
- 19. 無法更新jQuery mCustomScrollbar
- 20. JQuery mCustomScrollbar動態高度
- 21. Ajax刷新頁面內容而不是div內容
- 22. mCustomScrollbar「scrollTo」不工作
- 23. jQuery的AJAX/CakePHP的加載內容/段
- 24. 帶有ajax內容的滑塊 - jquery
- 25. 使用Jquery&Ajax的動畫內容
- 26. jquery cluetip - 清理ajax加載的內容
- 27. AJAX加載內容的jQuery函數
- 28. AJAX內容加載後的jQuery函數
- 29. jQuery的工具提示+ Ajax內容
- 30. jQuery UI中的AJAX內容Tooltip Widget
什麼是「#content_1」ID,在你的代碼? –
這是一個滾動內容div – AkilaH
包括時它工作正常。但通過ajax加載後,它不起作用 – AkilaH