如何使用 jQuery .subscribe()?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11919042/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:05:01  来源:igfitidea点击:

How to use jQuery .subscribe()?

jqueryjquery-pluginspublish-subscribestruts2-jquery

提问by Diego Ramos

I've been trying to use $.subscribebut it doesn't seem to work. I downloaded a WAR project where it does work but when I use this function in my project it doesn't work. Do I have to download an extra plugin?

我一直在尝试使用,$.subscribe但似乎不起作用。我下载了一个可以工作的 WAR 项目,但是当我在我的项目中使用这个功能时它不起作用。我必须下载额外的插件吗?

Because I couldn't find info about these functions in the jQuery website either, I just found the new $.Callbacks()function. The reason I need to use $.subscribeis so I can use something like onBeforeTopic.

因为我在 jQuery 网站上也找不到关于这些函数的信息,所以我刚刚找到了新$.Callbacks()函数。我需要使用的原因$.subscribe是我可以使用类似onBeforeTopic 的东西。

Thanks in advance.

提前致谢。

采纳答案by Bart Platak

You will need Publish/subscribe plugin.

您将需要发布/订阅插件

I stand corrected: you will need Struts2 jQuery Plugin.

我更正了:您将需要Struts2 jQuery Plugin

回答by onetwopunch

I know I'm a bit late to the party but why not just write your own simple pubsub? Check out this article: https://lowbrowcoder.wordpress.com/2015/02/16/pubsub-pattern-in-javascript/

我知道我参加聚会有点晚了,但为什么不编写自己的简单 pubsub 呢?查看这篇文章:https: //lowbrowcoder.wordpress.com/2015/02/16/pubsub-pattern-in-javascript/