English 中文(简体)
我如何在网站和古角展期之间用java字母出版/订阅“家长”?
原标题:How can I implement publish / subscribe "pattern" in javascript between a website and a google chrome extension?

I m 试图在网站和古角展期之间实行公共/次级模式。 迄今为止,我的大多数实验都一直在使用 j,因为它是强力的、有约束的辛迪加,但我是没有多少uck。

Background: I m working with an open source, Ruby/Rails-based Pomodoro Technique implementation. I ve modified the site s code to expose its activity using jQuery s $.trigger syntax to publish observable events for the start of a timer session and the end of a timer session. Those triggers work in so far as I can trace the execution into the jQuery event code. So the site is the publisher of a couple of relevant events.

我通过装满舱,并利用bin(Bbind) syntax对由该网址出版的习俗活动进行约束,在 go角展期完成交易。 该展期将装上该站点,并允许该场址的所有航道。

From the publication side I ve tried both $.event.trigger() and $(document).trigger() to be as general as possible, on the subscriber side I ve tried binding to several relevant elements, the most general being $(document).bind()

When I observe the custom event binding by pausing execution after the bind calls in the extension are executed and analyze the results of console.dir($(document).data( events )); I see the custom events I m trying to subscribe to in the list.

然而,当我收到一份书面文件时,数据(事件);在启动“定制”之前,即“必要”——即:在清单中。

我在如何开展工作时,忽略了一些明显的东西?

p.s. I should note that if I bind directly to the click event on the elements that trigger the changes my extension code work perfectly, but the DOM of the site changes during execution so the bindings break after not too long so I was hoping that some sort of pub-sub mechanism might be more sensible.

http://www.ohchr.org。

正如我在对“ChrisNZL”的答复中指出的那样,我尝试了......live()而不是.bind(),并且看到了同样的行为。

最佳回答

How are you interacting between the site and the extension?

Note that content scripts you inject through the extension APIs can t access the JavaScript of the main page, so there s no way you can get at the custom events you export in your jQuery code.

与此相关的工作是使用普通的全球范围文字注射(例如,向主要机构贴上文字标签)。 你们是否尝试这样做?

问题回答

http://api.jquery.com/live/rel=“nofollow”>.live(? 诸如.bind(),但附有“与现任选任人相匹配的所有要素”的手稿,现为,今后为,即具有约束力的笔记。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签