tags:

views:

166

answers:

1

I have a page that uses jquery ui's tabs. Each tab content is an iframe with a local page in it. These local pages have been importing their own jquery.js when their parent also have jquery.js imported.

Is there any way i can use the parents jquery inside the iframes, so I dont have to add jquery.js to every single page inside the iframe?

I know parent.$ may work, but I dont want to call parent on every function. Can i instantiate the jquery object from the parent?

A: 

Try var $ = parent.$, or something along those lines, at the beginning of your javascript.

Gausie
That was the first thing i tried. As far as I can remember, it did not work correctly. Will try again though
Contra
Doesn't work. The context html being searched with selector will be outside the iframe, the parent.
Contra
In that case, if your frame id was "frame" for example, you could put `$iframe = $('#frame').contents();` at the beginning, and use it in your selectors as follows `$('tag.someclass:someselector',$iframe)...`
Gausie