参考jQuery插件选项

参考jQuery插件选项,jquery,jquery-plugins,Jquery,Jquery Plugins,我正在使用inifiteScroll jquery插件,我想引用我版本的locding.start函数中的options变量: var rDealBone = this; ($('.deals-list'), this.el).infinitescroll({ navSelector : "div.navigation", nextSelector : "div.navigation a",

我正在使用inifiteScroll jquery插件,我想引用我版本的locding.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;
            }
        });
var rDealBone=this;
($('.deals list'),this.el).无限滚动({
导航选择器:“div.navigation”,
下一个选择器:“div.navigation a”,
项目选择器:“.deal”,
是的,
装载:{
完成:未定义,
finishedMsg:“祝贺你,你已经到达了互联网的尽头。”,
img:“http://www.infinite-scroll.com/loading.gif",
msg:null,
msgText:“正在加载下一组帖子…”,
选择器:null,
速度:“快”,
开始:函数(){
//这是插件默认启动函数的代码,
//选项指的是插件选项cariable,我该如何引用它
//从这个函数
$(opts.navSelector).hide();
opts.loading.msg
.appendTo(选择加载选择器)
.show(opts.loading.speed,function)(){
rDealBone.showMore();
});
}
},
路径解析:函数(){
返回“/listDeals/offset:”+rDealBone.doffset;
}
});
如何从start函数中引用插件选项


感谢您的帮助,Yehia。

在我看来,您似乎可以通过第一个参数访问它们:

opts.loading.start.call($(opts.contentSelector)[0],opts);
所以你会这样做:

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

我以前没有使用过这个插件,所以我自己也没有尝试过。

非常感谢,但是如果我想调用infinitescroll的_error函数$.infinitescroll._error(“结束”)该怎么办不幸的是,任何带有下划线的前缀都是私有的,因此不能通过“public”接口运行。尽管我不建议您这样运行:
$('.dealslist')。data('infinitescroll')。_error('end')
但是在github上打开一个问题,并提出一个案例,如果您有运行它的有效理由,那么将_error方法公开可能是值得的。此外,如果您确实想调用一个公共函数(任何不带下划线前缀的函数),应该这样调用:
$('.dealslist')。infinitescroll('methodName',arg1,arg2等);
不直接在
$上。infinitescroll
实际上是构造函数。(通常最好称为
$。infinitescroll
)非常感谢,我在