0

無限スクロールからコールバックする正しい方法は何ですか? 現在、この `

$(function() {
    code(); 
    $('#catview').infinitescroll({ 
        dataType: 'html',
        navSelector: 'div.nextPage',
        nextSelector: 'div.nextPage a:first',
        itemSelector: '#catalogue',
        loading: {
            finishedMsg: '',
            msgText: '',
            img: '/../../../images/loading.gif',
        },
        debug: true,
        animate: true 

    }, $(function() {
        code();
    }));
    });`

動作しません:( code() の前にアラートを設定すると、ページが読み込まれたときにアラートが表示され、それだけです...コードの他の部分は次のとおりです。

    function code() {
alert('1')
    $('.teest').caroufredsel({
        direction: 'left',
        circular: true, 
        items: {
            visible: 1, 
            minimum: 2, 
        },
        scroll: {
            fx: 'fade', 
            easing: 'easeOutCubic', 
            duration: 200, 
        },
        auto: {
            duration: 1600
        },
        width: 208,
        height: 265,
        prev: {
            button: '.prev'
        },
        next: {
            button: '.next'
        } 
    });
}

これらの 2 つのコードを実行した場合に表示されるのは、最初のページで動作している caroufredsel の alert 1 だけです。

4

2 に答える 2

0

$(function... はJavaScript エンジンからオブジェクトとして読み取られ、無限スクロールはオブジェクトをコールバックできません。関数からすべての $ を削除すると、すべてが解決します

于 2013-05-21T23:09:50.333 に答える
0

これを試してください:-

$(function() {

    $('#catview').infinitescroll({
        dataType: 'html',
        navSelector: 'div.nextPage',
        nextSelector: 'div.nextPage a:first',
        itemSelector: '#catalogue',
        loading: {
            finishedMsg: '',
            msgText: '',
            img: '/../../../images/loading.gif',
        },
        debug: true,
        animate: true 
    },
    function(arrayOfNewElems)
    {
         code();
    });
});

Infinite Scroll Jquery ドキュメントのコールバック関数に従って、コードを変更してください

 $(function() {
    code();
 }));

function(arrayOfNewElems){
 //here your collaback function
});
于 2013-05-21T06:21:49.250 に答える