0

我已经很好地完成了滚动条jQuery custom content scroller,但是有一些问题。正是我用 div 标签完成了这个滚动条,我在其中从 mysql 检索数据(一些帖子),所以我的问题是我正在使用 ajax 将数据发送到数据库并且它也可以工作,但是当附加数据时在 div 标签上,滚动条的大小是固定的,它不会更新(仅在页面刷新时更新)。如何在使用 ajax 添加数据时更新滚动条大小?而且我不明白如何在最后修复滚动条?请帮助我对这个问题很困惑,谢谢:)

PS。这里也是插件主页http://manos.malihu.gr/jquery-custom-content-scroller

更新

$.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() 函数才值得注意

4

1 回答 1

1

看看流体滚动条演示

编辑

如果这不起作用,请尝试.mCustomScrollbar()在您的 ajax 请求之后重新初始化 -functon。

编辑 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
                    }
                });
            }
        });
    }
});​
于 2012-08-23T12:28:34.733 回答