参考 jQuery 插件选项

发布于 2024-12-26 18:14:35 字数 1565 浏览 0 评论 0原文

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

        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;
            }
        });

How can I reference to the plugin options from inside the start function?

感谢您的帮助,叶希亚。

I'm using the inifiteScroll jquery plugin, and I want to reference the options variable from my version of the locading.start function:

        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;
            }
        });

How can I reference to the plugin options from inside the start function?

Appreciate the help, Yehia.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只为一人 2025-01-02 18:14:35

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

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

所以你会这样做:

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

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

Looks to me as if you can access them through the first param:

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

So you'd do:

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

I've not used this plugin before so I've not tried this myself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文