Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:07:57+00:00 2026-05-25T19:07:57+00:00

I’m trying to implement a pub/sub pattern between a website and a google chrome

  • 0

I’m trying to implement a pub/sub pattern between a website and a google chrome extension. Most of my experimentation thus far has been using jQuery due to its strong bind/trigger syntax but I’ve been having little luck.

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.

I’ve implemented the listener/subscriber end of the transaction in a google chrome extension by loading jquery and using the .bind() syntax to bind to the custom events being published by the site. The extension is loading for the site and has permissions set for all paths within the url for the site.

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.

However when I analyze the results of console.dir($(document).data(‘events’)); just before triggering the custom event on the website side, the requisite event handlers do not appear in the list.

Am I missing something obvious in how this should work?

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.

EDIT

As noted in my response to @ChrisNZL’s answer, I’ve tried .live() instead of .bind() and see the same behavior.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:07:58+00:00Added an answer on May 25, 2026 at 7:07 pm

    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.

    A workaround to this is to use ordinary global scope script injection (ie. append a script tag to the main body). Have you tried doing this?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.