Close Fancybox Called from A Dynamically Loaded Page
I am trying to close a Fancybox automatically (using parent.$.fancybox.close(); ), but for some reason it is not working because the Fancybox was initiated from some dynamically loaded content using .load() with Jquery. Is there some kind of special code I need to tag along wit开发者_StackOverflow社区h the close function to let fancybox know it was initiated from an external source?
If you're using load
to display content via AJAX, then parent
is not needed. This is because the AJAX content is added directly to the main page's DOM tree. You should only use parent
if you're loading an iframe and want to close from within the iframe. If you want to cover both cases use:
top.$.fancybox.close();
(This will work as long as the main page isn't displayed within a frame.)
If this doesn't answer your question, please provide more details on where you're trying to close the fancy box from -- from a user-triggered link in the content? from within a script in the loaded content? from within a script in the main page?
精彩评论