[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-26 Thread Paul Mills
That's what I tried first but couldn't get it to work, so I switched to using load function. I've created a demo page with 2 iframes - one using each method and only the load function works. You can find it here if you want to have a look to see if I've done something wrong.

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-26 Thread ricardobeat
Hope you don't mind turning your thread into a discussion :) now that sounds like a bug. $(document).ready(function(){ $(frames.testframe2.document).ready(function(){ $('#test',frames.testframe2.document); }); }); The inner ready() function is fired exactly at the same time as

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-26 Thread Geuis
I keep seeing people talking about different ways to access the document of an iframe. This method(after much hairpulling and testing) works very well. $('iframeID').contents() The .contents() method will automatically handle the browser differences between contentWindow and contentDocument. It

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-25 Thread hubbs
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:

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-25 Thread ricardobeat
You need to put the code inside the $(document).ready function, it's not finding the iframe because the DOM is not loaded. - ricardo On Sep 25, 12:36 pm, hubbs [EMAIL PROTECTED] wrote: Well, I tried this, but again it is not working, I really must be missing something. All I want to do it

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-25 Thread Paul Mills
The ready function fires when the iframe is ready in the DOM, not when the contents of the iframe are ready. I think you need to use the load function - a bit like this: $(window).load(function () { $('#test',

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-25 Thread ricardobeat
Oh, that's right. But I think the best way would be $(document).ready(function(){ //theother code blabla //now that the iframe element exists $(frames.testframe.document).ready(function(){ }); }); On Sep 25, 4:56 pm, Paul Mills [EMAIL PROTECTED] wrote: The ready function

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-24 Thread ricardobeat
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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-24 Thread hubbs
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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-24 Thread ricardobeat
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* $('bTESTE/b').appendTo('body').click(function(){ // append element to the *parent frame* and assing a click handler to it

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-23 Thread hubbs
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:

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-22 Thread hubbs
So, would this be in addition to my normal document ready? 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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-17 Thread ricardobeat
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,

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-17 Thread hubbs
Well, I had this same thing working before. But it does not solve the problem of using the parent frames instance of jQuery, which I don't know how to do. Using your example inserts the DOM elements, but they don't get the events, because they don't don't use the parents jQuery, which is the

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-17 Thread hubbs
Ok, I have the following in my iframe: $(document).ready(function() { $ = window.parent.$; $(#test).click(function() { $(#hold).append('a href=#Inserted from iFrame/a br /'); }); }); This seems to be what I would need, but now it won't load content

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-17 Thread hubbs
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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-17 Thread ricardobeat
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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-16 Thread hubbs
Ok Brandon, I found this in another post: var doc = $('#testframe')[0].contentWindow.document; $(doc.body).append('spantest/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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-16 Thread ricardobeat
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

[jQuery] Re: Bind events on DOM elements inserted from other frame

2008-09-16 Thread hubbs
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