0

The following jQuery is loaded by a website I'm using:

$("#table").trigger("update");

If I add the following to the bottom of the file that is loaded by the website (using local editing):

$("#table").on('update', function() {console.log('updated!');});

It works! When the "update" event is triggered, the console message is logged.

But, if I add the exact same jQuery to the bottom of the Google Chrome extension's JS file it does not log the console message.

However, if I add

$("#table").on('click', function() {console.log('click');});

Then when I click on it the console message is logged.

Why could this be? There is nothing I can find in the event or subsequent handlers that would prevent it from being passed further along the chain.

manifest.json contains:

"content_scripts": [
    {
      "matches": [
        "<works>*"
      ],
      "run_at": "document_end",
      "js": [
        "scripts/jquery-1.12.4.min.js",
        "scripts/prototype.js"
      ],
      "all_frames": false
    }
  ]
JohnFF
  • 723
  • 5
  • 20

1 Answers1

0

The following appears to be the reason:

Can't trigger click with jQuery in a Chrome extension

"The root cause of the problem is that extension content scripts execute in an isolated world. One of the reasons for this is so that your code does not conflict with the page's code: for instance, you can use a different version of jQuery."

As a native event, I could engage with clicks, even if they are triggered by the code outside the extension. As a non-native event 'update' I cannot.

JohnFF
  • 723
  • 5
  • 20