2012-08-23 170 views
0

我已經完成滾動條與jQuery custom content scroller就好,但有一些問題。確切地說,我已經完成了這個帶有d​​iv標籤的滾動條,其中我從mysql(某些帖子)中檢索數據,所以我的問題是我使用ajax將數據發送到數據庫並且它也可以工作,但是當數據被追加在div標籤上,scroller具有固定的大小,它不是續訂(只有刷新頁面時才更新)。用Ajax添加數據時如何更新滾動條大小?而且我也無法理解最後如何修復滾動條?請幫助我很困惑這個問題,謝謝:)jQuery自定義內容滾動滾動

PS。這裏插件主頁太http://manos.malihu.gr/jquery-custom-content-scroller

UPDATE

$.ajax({ 
       url: "ajax/posting.php", 
       type: "POST", 
       data: {send_post: "Send", user_id: "<?php echo $userArr[0]; ?>", user_name: "<?php echo $userArr[2] . " " . $userArr[3]; ?>", msg: $("#post").val()}, 
       complete: function(){ 
        $("#post").val(""); 
       }, 
       success: function(result){ 
        $.ajax({ 
         url: "ajax/posting.php", 
         type: "POST", 
         data: {renew_posts: "Yes",admin: "<?php echo $userArr[1]; ?>",owner: "<?php echo $userArr[0]; ?>"}, 
         success: function(renewed_data){ 
          $("#chat_tb").html(renewed_data); 
          (function($){$(window).load(function(){$(".post_container").mCustomScrollbar({ 
           scrollButtons:{enable:true,scrollSpeed: 40} 
          });});})(jQuery); 
         } 
        }); 
       } 
      }); 

在這個代碼僅值得注意的是如何將數據發送到數據庫後更新mCustomScrollbar()回調中的功能,

回答

1

看看在Fluid scrollbar demo

編輯

如果不嘗試的作品在Ajax請求後重新初始化.mCustomScrollbar() -functon。

EDIT 2

只是一種嘗試:

$.ajax({ 
    url: "ajax/posting.php", 
    type: "POST", 
    data: { 
     send_post: "Send", 
     user_id: "<?php echo $userArr[0]; ?>", 
     user_name: "<?php echo $userArr[2] . "" . $userArr[3]; ?>", 
     msg: $("#post").val() 
    }, 
    complete: function() { 
     $("#post").val(""); 
    }, 
    success: function(result) { 
     $.ajax({ 
      url: "ajax/posting.php", 
      type: "POST", 
      data: { 
       renew_posts: "Yes", 
       admin: "<?php echo $userArr[1]; ?>", 
       owner: "<?php echo $userArr[0]; ?>" 
      }, 
      success: function(renewed_data) { 
       $("#chat_tb").html(renewed_data); 
       $(".post_container").mCustomScrollbar({ 
        scrollButtons: { 
         enable: true, 
         scrollSpeed: 40 
        } 
       }); 
      } 
     }); 
    } 
});​ 
+0

我已爲自己這個頁面,剛剛發佈的問題,因爲不明白該怎麼做 – tnanoba

+0

它必須是書面withing阿賈克斯成功腳本是? – tnanoba

+0

而且我已經閱讀過文檔,但我猜不知道如何在默認情況下最終修復它,這有可能嗎? – tnanoba