Side navigation
#8155 closed feature (invalid)
Opened February 03, 2011 10:06AM UTC
Closed February 03, 2011 10:35AM UTC
Last modified February 03, 2011 02:56PM UTC
Architectural question about reusing jQuery inside iframes
Reported by: | marantz | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
My environment is composed by an html main page that host an iframe where dynamic content is injected.
Main html page uses jQuery internally for some ajax processing, also each html dynamically loaded from web server into the iframe need a reference to an initialization script (called from main page using the onload event of iframe).
iframe html content, runs the externally invoked javascript function to setup some fields into forms.
Inside iframe script, i can use "parent.$(...)" to access the jQuery library hosted into main html page.
While some functions like $.ajax() works, a selector like parent.$("#myid") don't work, probably because the 'document' that the parent jQuery sees is the main HTML page, and not the iframe content.
The question is: how can i reuse the parent jQuery to have the 'scope' of the inner iframe ? Can a "clone" of jQuery (made by function running into iframe) be initialized to have iframe document as root document ?
Also, can the parent jQuery library (referenced inside iframe) coesist with another instance of jQuery loaded from the html inside the iframe ?
So, the global question is how to "initialize" a working instance of a jQuery library inside an iframe, giving a reference of the library living on the parent document.
Attachments (0)
Change History (2)
Changed February 03, 2011 10:35AM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed February 03, 2011 02:56PM UTC by comment:2
I apologize for having used this issue tracking unappropriately.
My original thoughts was to file an enhancement request of the jQuery.sub() function in order to accept an alternate root DOM document as parameter.
For example:
val loc_jQuery = parent.$.sub(document)
Then, loc_jQuery can be used now with selectors having local document scope, at the opposite of the instance already living on parent that will still use it's own original document.
My request is if this is feasible from a architectural point of view, or if do exist any workaround to achieve the same result, when a document inside an iframe want for some reasons reuse the library instance loaded on iframe parent.
Replying to [comment:1 jitter]:
Although this is an interesting question, the jQuery bug tracker is not the right venue for this. Please repost such questions on the jQuery Forum, where this can be discussed in depth. The jQuery bug tracker is not for such support requests, but only to handle bugs found in jQuery core. After posting on the jQuery Form please leave a link to the discussion in a comment.
Although this is an interesting question, the jQuery bug tracker is not the right venue for this.
Please repost such questions on the jQuery Forum, where this can be discussed in depth. The jQuery bug tracker is not for such support requests, but only to handle bugs found in jQuery core.
After posting on the jQuery Form please leave a link to the discussion in a comment.