infinitescroll.js的自定义脚本回调

Custom Script callback for infinitescroll.js

本文关键字:脚本 回调 自定义 js infinitescroll      更新时间:2023-09-26

所以网上有很多关于这方面的文章,都是一样的,都不起作用

我想做的是在无限滚动运行后运行JS函数。

当我尝试运行它时,我会遇到语法错误SyntaxError:缺少:在属性id之后,函数(arrayOfNewElems){

<script>
    if ( ! navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
        var infinite_scroll = {
            loading: {
                img: "<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif",
                msgText: "<?php _e( 'Loading the next set of products...', 'woothemes' ); ?>",
                finishedMsg: "<?php _e( 'All products loaded.', 'woothemes' ); ?>"
            }, function(arrayOfNewElems) {
                        $('img')equalHeights();
                    });,
            "nextSelector":".pagination a.next",
            "navSelector":".pagination",
            "itemSelector":"#main .product",
            "contentSelector":"#main ul.products"
        };
        jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll );
    }
    </script>

有人知道究竟如何运行equalHeights()函数吗;

有很多语法错误,所以我一开始很容易。

   var infinite_scroll = {
        obj: {
            prop1 : val1,
        }, function() {}
    };

所以有一个问题。您必须为函数命名。但你想什么时候叫它?装载什么时候完成?它必须看起来像这样:

   var infinite_scroll = {
        loading: {
            finished : function() {}
        }
    };

在您的函数中,您有另一个语法错误:

$('img')equalHeights();

应为:$('img').equalHeights();