1

我一直在研究这段代码。一旦画廊页面加载了ajax,我正在尝试实现SmoothDivScroll jquery 插件。这是我的 ajax js。请注意,如果不使用 ajax 加载画廊,smoothdivscroll 可以正常工作。

$(document).ready(function(){

    $('.more').live('click',function(){
        var href = $(this).attr('href');
        if ($('#ajax').is(':visible')) {
            $('#ajax').css('display','block').animate({height:'1px'}).empty();
        }
        $('#ajax').css('display','block').animate({height:'380px'},function(){
            $('#ajax').html('<img class="loader" src="images/loader.gif" alt="">');
            $('#ajax').load('content.php #'+href, function(){
                $('#ajax').hide().fadeIn().highlightFade({color:'#717171'});
            });
        });
        return true;
    });

    $("div#makeMeScrollable").smoothDivScroll({
        mousewheelScrolling: true,
        manualContinuousScrolling: true,
        visibleHotSpotBackgrounds: "always",
        autoScrollingMode: "onstart"
    });

});

更新:虽然@Mathletics 回答确实通过在回调中调用插件来加载插件,但smoothscrollingdiv 并不那么顺利。图片不是内​​联的,滑动非常生涩。无需通过ajax加载它就可以正常工作。下面我提供了链接,说明使用 ajax 和不使用 ajax 的样子。

Ajax 加载:从菜单中选择图库

没有阿贾克斯:这就是画廊应该有的样子

4

1 回答 1

1

smoothDivScroll呼叫移动到您的回调中。

$(document).ready(function(){

    $('.more').live('click',function(){
        var href = $(this).attr('href');
        if ($('#ajax').is(':visible')) {
            $('#ajax').css('display','block').animate({height:'1px'}).empty();
        }
        $('#ajax').css('display','block').animate({height:'380px'},function(){
            $('#ajax').html('<img class="loader" src="images/loader.gif" alt="">');
            $('#ajax').load('content.php #'+href, function(){
                $('#ajax').hide().fadeIn().highlightFade({color:'#717171'});
                    $("div#makeMeScrollable").smoothDivScroll({
                    mousewheelScrolling: true,
                    manualContinuousScrolling: true,
                    visibleHotSpotBackgrounds: "always",
                    autoScrollingMode: "onstart"
                });

            });
        });
        return true;
    });


});
于 2012-08-02T18:18:29.077 回答