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.