[jQuery] Re: Bind events on DOM elements inserted from other frame
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. http://jquery.sallilump.com/bindtest/bind.html Paul On 26 Sep, 01:46, ricardobeat [EMAIL PROTECTED] wrote: 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 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', frames['testframe'].document).click(function() { $(#hold).append('a href=#Inserted from iframe/a br /'); }); }); Paul On Sep 25, 6:37 pm, ricardobeat [EMAIL PROTECTED] wrote: You need to put the code inside the $(document).ready function, it's not finding theiframebecause 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 be able to click the link inside theiframe, 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 Iframepage: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(){ //bindfunction to event from element *insideiframe* $('bTESTE/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 aniframe, it is hardcoded. I am trying to append to the parent document from within theiframe, and have the event in the parent bound to the appended element from theiframe. 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 theiframe? 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 fromiFrame/a br /'); In theiframe, 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 canbindevents within theiframe. 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 theiframe'sjQuery object: $('.classinparentframe', parent.window.document) Ideally if the contents of theiframeare 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] Re: Bind events on DOM elements inserted from other frame
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 the parent document. So, the jQuery object returns empty because the DOM is not loaded for the iframe yet. I wonder why is the function fired if the DOM is not ready? It would be nice to have the same advantages ready() offers over the load event for iframes. Any thoughts? - ricardo On Sep 26, 6:11 am, Paul Mills [EMAIL PROTECTED] wrote: 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.http://jquery.sallilump.com/bindtest/bind.html Paul On 26 Sep, 01:46, ricardobeat [EMAIL PROTECTED] wrote: 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 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', frames['testframe'].document).click(function() { $(#hold).append('a href=#Inserted from iframe/a br /'); }); }); Paul On Sep 25, 6:37 pm, ricardobeat [EMAIL PROTECTED] wrote: You need to put the code inside the $(document).ready function, it's not finding theiframebecause 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 be able to click the link inside theiframe, 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 Iframepage: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(){ //bindfunction to event from element *insideiframe* $('bTESTE/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 aniframe, it is hardcoded. I am trying to append to the parent document from within theiframe, and have the event in the parent bound to the appended element from theiframe. 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 theiframe? 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 fromiFrame/a br /'); In theiframe, 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 canbindevents within theiframe. 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:
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 will give you standard access to the iframe document no matter what browser. Further, if there are particular non-jQuery things you want to do in an iframe, its still a great way to do it. So for example, a problem I have been working on for several weeks involves adding a script into the iframe which itself calls another script for our forum system(Jive) that displays a list of comments. As a sidenote, the commenting system in Jive absolutely SUCKS. No caching, does document.writes, etc. The forum bit is really nice, but the comment system needs to be shot. So I am loading an iframe into the dom, then writing the script that loads the Jive comments into the iframe. When I was using the strict jQuery methods: $('#commentiframe').contents().find('body').html(scriptvar) It would write into the iframe, but it conflicted with some of the ads we serve on our site. Jive's comment widget does a bunch of document.write's into the document, and using the standard jQuery method the comments were being added to the page at the first occurrence of a script tag. Very, very wierd. So, the way I found around that was to drop back into normal javascript methods and came up with this: $('iframe id=commentiframe src='+scriptvar+'/ iframe').appendTo('body'); f=$('#commentiframe').contents()[0]; f.open(); f.write(scriptvar); f.close();
[jQuery] Re: Bind events on DOM elements inserted from other frame
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* $('bTESTE/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('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 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,
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 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* $('bTESTE/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('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 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
[jQuery] Re: Bind events on DOM elements inserted from other frame
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', frames['testframe'].document).click(function() { $(#hold).append('a href=#Inserted from iframe/a br /'); }); }); Paul On Sep 25, 6:37 pm, ricardobeat [EMAIL PROTECTED] wrote: You need to put the code inside the $(document).ready function, it's not finding theiframebecause 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 be able to click the link inside theiframe, 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 Iframepage: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(){ //bindfunction to event from element *insideiframe* $('bTESTE/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 aniframe, it is hardcoded. I am trying to append to the parent document from within theiframe, and have the event in the parent bound to the appended element from theiframe. 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 theiframe? 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 fromiFrame/a br /'); In theiframe, 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 canbindevents within theiframe. 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 theiframe'sjQuery object: $('.classinparentframe', parent.window.document) Ideally if the contents of theiframeare 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('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 context of the
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 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', frames['testframe'].document).click(function() { $(#hold).append('a href=#Inserted from iframe/a br /'); }); }); Paul On Sep 25, 6:37 pm, ricardobeat [EMAIL PROTECTED] wrote: You need to put the code inside the $(document).ready function, it's not finding theiframebecause 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 be able to click the link inside theiframe, 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 Iframepage: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(){ //bindfunction to event from element *insideiframe* $('bTESTE/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 aniframe, it is hardcoded. I am trying to append to the parent document from within theiframe, and have the event in the parent bound to the appended element from theiframe. 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 theiframe? 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 fromiFrame/a br /'); In theiframe, 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 canbindevents within theiframe. 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 theiframe'sjQuery object: $('.classinparentframe', parent.window.document) Ideally if the contents of theiframeare 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,
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 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('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 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
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 entire problem. How can I use the parents instance of jQuery as you say? 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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 into the parent...arg. 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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?
[jQuery] Re: Bind events on DOM elements inserted from other frame
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('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 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?