Reputation: 6665
I have a page that has the following javascript:
var w = window.open("somePage.html", '', 'width=500, height=500');
$(w).bind('someEvent', function() { alert('I see the event!'); });
and on somePage.html I attempt to trigger the event:
$(window).trigger('someEvent', '');
The event doesn't fire (it does however if I do the event binding and trigger on the same page). I have tried all sorts of variations of binding such as using this and this.window
Am I somehow not referencing the right object from the binding side?
(I am testing this in Chrome and Firefox)
edit:
David Rodrigues was kind enough to create a jsfiddle of this question: http://jsfiddle.net/KARgF/ & http://fiddle.jshell.net/vTQ9U/
Upvotes: 0
Views: 2427
Reputation: 77378
I think the problem is that $
still refers to the jquery in the host window. If you do this:
var w = window.open("somePage.html", '', 'width=500, height=500');
var $ = w.$;
$(w).bind('someEvent', function() { alert('I see the event!'); });
you should be good to go.
Upvotes: 2