Well, I tried this, but again it is not working, I really must be missing something.
All I want to do it be able to click the link inside the iframe, and have it append some HTML into the parent, and apply a click event as well, that is all, seems simple! :) My test page: http://web2.puc.edu/PUC/files/bind.html Iframe page: http://web2.puc.edu/PUC/files/iframe.html Thanks for all the help. On Sep 24, 3:02 pm, ricardobeat <[EMAIL PROTECTED]> wrote: > Hi, > > This works for me (FF3) (code running in the parent frame): > > $('#test',frames[0].document).click(function(){ //bind function to > event from element *inside iframe* > $('<b>TESTE</b>').appendTo('body').click(function(){ // append > element to the *parent frame* and assing a click handler to it > alert('test'); > }); > > }); > > I might not be understanding clearly what you want, a test case or > explanation of the functionality you are looking for might help. > > cheers, > - ricardo > > On Sep 24, 1:27 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > Hi Ricardo, > > > I am not appending an iframe, it is hardcoded. I am trying to append > > to the parent document from within the iframe, and have the event in > > the parent bound to the appended element from the iframe. > > > On Sep 23, 11:49 pm, ricardobeat <[EMAIL PROTECTED]> wrote: > > > > Hi, I can't test anything right now, but are you setting up the > > > ready() function after appending the iframe? > > > > On Sep 23, 9:11 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > > Yeah, this really is not working. Could someone please help me to > > > > understand how to make multiple frames use the same jquery instance so > > > > I can resolve this problem? Do I need to resort to frame ready > > > > plugin? I really don't want to... > > > > > On Sep 17, 7:12 pm, ricardobeat <[EMAIL PROTECTED]> wrote: > > > > > > Not sure but $(frames['frame'].document).ready() should work (from the > > > > > parent window). > > > > > > On Sep 17, 8:21 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > > > > Ok, I am realizing it has to do with the do with the > > > > > > $(document).ready > > > > > > function. If I just use: > > > > > > > $ = window.parent.$; > > > > > > $("#hold").append('<a href="#">Inserted from iFrame</a> <br />'); > > > > > > > In the iframe, it correctly adds the link to the parent, and it gets > > > > > > the event from livequery! Hooray!! > > > > > > > But, obviously I need to add back a document ready function so that > > > > > > I > > > > > > can bind events within the iframe. How does that need to be done in > > > > > > this context? As I said, using the normal document ready does not > > > > > > work. > > > > > > > On Sep 17, 9:58 am, ricardobeat <[EMAIL PROTECTED]> wrote: > > > > > > > > using the iframe's jQuery object: > > > > > > > > $('.classinparentframe', parent.window.document) > > > > > > > > Ideally if the contents of the iframe are always known to you, you > > > > > > > should use only one instance of jQuery on the parent window and > > > > > > > do all > > > > > > > your stuff from it, it's simpler to debug also. > > > > > > > > On Sep 16, 10:29 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > > > > > > Thanks Ricardo. > > > > > > > > > But what if I wanted to access the parent document from WITHIN > > > > > > > > the > > > > > > > > iframe? > > > > > > > > > On Sep 16, 12:27 pm, ricardobeat <[EMAIL PROTECTED]> wrote: > > > > > > > > > > You need to understand that a frame is another 'window' > > > > > > > > > instance, it > > > > > > > > > doesn't have the same jQuery object as the parent window > > > > > > > > > unless you > > > > > > > > > tell it to. So the '$' object you use in firebug console is > > > > > > > > > always the > > > > > > > > > one from the parent window. > > > > > > > > > > If i'm not mistaken you can acess frame content with the > > > > > > > > > parent > > > > > > > > > window's jQuery object using $('.classinsidetheframe', > > > > > > > > > frames['name'].document).css(); > > > > > > > > > > On Sep 16, 1:48 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > Ok Brandon, > > > > > > > > > > > I found this in another post: > > > > > > > > > > > var doc = $('#testframe')[0].contentWindow.document; > > > > > > > > > > $(doc.body).append('<span>test</span>'); > > > > > > > > > > > This seems like it would help, but I am not sure how to use > > > > > > > > > > this, > > > > > > > > > > along with what you posted to get it working correctly. > > > > > > > > > > Somehow > > > > > > > > > > sending the GET within the context of the contentWindow is > > > > > > > > > > confusing > > > > > > > > > > me, and I just can't get it working. > > > > > > > > > > > On Sep 15, 9:18 am, "Brandon Aaron" <[EMAIL PROTECTED]> > > > > > > > > > > wrote: > > > > > > > > > > > > To see what I mean run this in Firebug: > > > > > > > > > > > $('iframe')[0].contentWindow.$ = $; > > > > > > > > > > > > Then click on the link in the iframe and it will behave > > > > > > > > > > > as you expect. > > > > > > > > > > > > -- > > > > > > > > > > > Brandon Aaron > > > > > > > > > > > > On Mon, Sep 15, 2008 at 9:13 AM, Brandon Aaron <[EMAIL > > > > > > > > > > > PROTECTED]>wrote: > > > > > > > > > > > > > This would work if you used the frames parent instance > > > > > > > > > > > > of jQuery. LiveQuery > > > > > > > > > > > > works by monitoring the DOM methods within jQuery. > > > > > > > > > > > > Since within the frame > > > > > > > > > > > > you are using a new instance of jQuery, LiveQuery will > > > > > > > > > > > > not be monitoring its > > > > > > > > > > > > DOM methods. > > > > > > > > > > > > -- > > > > > > > > > > > > Brandon Aaron > > > > > > > > > > > > > On Sun, Sep 14, 2008 at 11:04 PM, hubbs <[EMAIL > > > > > > > > > > > > PROTECTED]> wrote: > > > > > > > > > > > > >> I can confirm that using event delegation will fix > > > > > > > > > > > >> this problem. I > > > > > > > > > > > >> guess that it is just a problem with the LiveQuery > > > > > > > > > > > >> plugin. Brandon, > > > > > > > > > > > >> if you are where around here, could you comment on > > > > > > > > > > > >> this? > > > > > > > > > > > > >> Thanks. > > > > > > > > > > > > >> On Sep 14, 2:29 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > >> > I have a working example of this, and would really > > > > > > > > > > > >> > like help > > > > > > > > > > > >> > understanding why bind or livequery does not bind > > > > > > > > > > > >> > events to DOM > > > > > > > > > > > >> > elements that are inserted from an iframe. > > > > > > > > > > > > >> >http://web2.puc.edu/PUC/files/bind.html > > > > > > > > > > > > >> > Clicking the "insert from frame" link will append > > > > > > > > > > > >> > links to the parent > > > > > > > > > > > >> > frame, which won't pick up the click event. But, > > > > > > > > > > > >> > clicking the "insert > > > > > > > > > > > >> > from body" link will append links within the same > > > > > > > > > > > >> > frame and will > > > > > > > > > > > >> > correctly have the click events bound. > > > > > > > > > > > > >> > Why is this happening? > > > > > > > > > > > > >> > On Sep 12, 9:02 pm, hubbs <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > >> > > I have been experiencing strangeness with trying > > > > > > > > > > > >> > > tobindevents to DOM > > > > > > > > > > > >> > > elements that have been inserted from a different > > > > > > > > > > > >> > > frame using .get(). > > > > > > > > > > > >> > > For some reason the elements don't be binded with > > > > > > > > > > > >> > > the events if they > > > > > > > > > > > >> > > are inserted from other frame. In testing, if I > > > > > > > > > > > >> > > try the same > > > > > > > > > > > >> thingwithinthe SAME frame the the events get binded > > > > > > > > > > > >> correctly. > > > > > > > > > > > > >> > > Am I missing something here? Is this a limitation > > > > > > > > > > > >> > > of jQuery?