Ticket #8155 (closed feature: invalid)
Architectural question about reusing jQuery inside iframes
|Reported by:||marantz||Owned by:|
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).
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.