Good morning peoples.
I am mid way through building a very complex application using jquery.
In short modules are loaded into iframes (to keep sandboxing and allow for varying things).
I am having a bit of trouble referencing the jquery object / library in the iframe (from it's parent).
I can write functions that are included in the parent and call them with parent.$().mymodule({...}); where the module has to scan the document for the iframe then retrieve it's content then look for the elements to apply the methods to (bit long winded but it works!!)..
THis morning I decided there must be a better way to do it and thats to add the functions for the module directly into the Iframe so they have some context, the trouble is that I cannot reference the jquery object from the parent at all inside the iframe .. I assumed that parent.$("").show("#some-element-in-the-iframe") would have enough context to select an element in the Iframe but it just seems to try and find that element in the parent document.
What I would like to know is....
Is there a way I can use the jquery loaded into the parent and its methods or do I have to load a seperate instance of jquery into the iframe - and if I have to load this new instance of jquery will it load from client cache or will it have to download the library again from the server.
It seems it should be possible but that "parent" seems to switch the context of the selector back to the parent document.
I have tried to add the context parameter into parent.$("#some-element","#iframe-id") but that doesnt work either.
Thanks in advance for any advice / guidance.
Alex