0

I'm doing the isolated context message passing in a Chrome extension. This doesn't really matter but what matters is it won't work with basic $(document).trigger() and $(document).on() (already tried including jQuery on both sides and it won't work).

So we're sticking with standard JS. Now in their example, they say to listen to a custom event:

 document.addEventListener('POLL',function(event){ 
     chrome.extension.sendRequest({poll:true, at:(new Date().getTime())}); 
 });

And to fire that event as required:

var ce = document.createEvent('Event');
ce.initEvent('POLL',true,true);
document.dispatchEvent(ce);
delete ce;

As you can see, POLL is my custom event. Now, how do I stick some data to it?

I've googled the whole Internet and found zilch, must be looking for the wrong keywords lol.

Silviu-Marian
  • 10,105
  • 5
  • 45
  • 71
  • 2
    possible duplicate of [Is there any way of passing additional data via custom events?](http://stackoverflow.com/questions/9417121/is-there-any-way-of-passing-additional-data-via-custom-events) – Felix Kling May 12 '12 at 13:31
  • Should've worked but looks like it doesn't. It won't pass anything through, except the target DOM node. – Silviu-Marian May 12 '12 at 13:46

0 Answers0