Triggering a jQuery event from iframe -



Triggering a jQuery event from iframe -

here's scenario, have events happening within iframe , until working well. ran problem want dispatch event iframe parent.

i'm using trigger event iframe:

$('body', window.parent.document).trigger('eventname'); //and i've tried $(window.parent.document).find('body').trigger('eventname');

and in parent page i've listening event this:

$('body').bind('eventname', myfunction)

i know script gets trigger because stuck console.log before , after trigger. iframe on same domain there no problem there.

i can phone call function on parent page straight this: window.parent.functionname wondering if possible using using event based solution.

solved

@cwolves reply working great:

parent.$('body').trigger( 'eventname' );

if have jquery loaded in parent frame, try:

parent.$('body').trigger( 'eventname' );

if not, seek this, i'm not sure if work looked @ jquery source , think may:

var pbody = $( parent.document.body ); pbody.trigger( 'eventname', pbody.data() );

(and same thing when binding eventname) issue, far can tell, jquery using info local page, causing issues because looks it's trying load info other frame. in other words, it's mess, there data params accepted in .bind, .trigger, etc.

jquery iframe

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -