开发者

Multiple instances of jQuery in an iframe and parent

开发者 https://www.devze.com 2023-02-22 21:05 出处:网络
I have a page that has a link to jQuery and a couple plugins, mainly jqModal. The page has multiple 开发者_Python百科links that open modal windows.The modal window uses an iframe to show its content,

I have a page that has a link to jQuery and a couple plugins, mainly jqModal.

The page has multiple 开发者_Python百科links that open modal windows. The modal window uses an iframe to show its content, and inside the modal is a page that again links to jQuery and jqModal. Everything seems to work alright until I close the modal and try to open another modal using the links on the parent page.

After closing the window, any subsequent clicks on modal links gives me an error saying jQuery ($) is not defined (specifically $("#" + name).jqm is not a function, where $('#name').jqm instantiates the modal window).

I've tried using jQuery.noConflict() but to no avail, as all the plugins use the same $ jQuery variable and the structure of the site doesn't allow for multiple variables to different instances of jQuery.

Is there any way to re-link jQuery after the modal window is closed so I can regain access to the other modal links?

Thanks


since jquery version 1.5 you can use the jQuery.sub() function to create multiple instance of jQuery.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号