参考jQuery插件选项

时间:2012-01-12 23:11:03

标签: jquery jquery-plugins

我正在使用inifiteScroll jquery插件,我想从我的locading.start函数版本中引用options变量:

        var rDealBone = this;
        ($('.deals-list'), this.el).infinitescroll({
            navSelector  : "div.navigation",
            nextSelector : "div.navigation a",
            itemSelector : ".deal",
            debug: true,
            loading: {
                finished: undefined,
                finishedMsg: "<em>Congratulations, you've reached the end of the internet.</em>",
                img: "http://www.infinite-scroll.com/loading.gif",
                msg: null,
                msgText: "<em>Loading the next set of posts...</em>",
                selector: null,
                speed: 'fast',
                start: function(){ 
                    // this is the code from the default start function of the plugin,
                    // the opts refers to the plugin options cariable, how can i refere to it
                    // from this function
                    $(opts.navSelector).hide();
                        opts.loading.msg
                            .appendTo(opts.loading.selector)
                            .show(opts.loading.speed, function () {
                                rDealBone.showMore();
                        });

                }
            },
            pathParse: function(){
                return '/listDeals/offset:' + rDealBone.doffset;
            }
        });

如何从start函数中引用插件选项?

赞赏帮助,Yehia。

1 个答案:

答案 0 :(得分:1)

在我看来,好像你可以通过第一个参数访问它们:

opts.loading.start.call($(opts.contentSelector)[0],opts);

所以你要这样做:

start: function (opts) { console.log(opts);  }

之前我没有使用过此插件,所以我自己也没试过。