admin管理员组

文章数量:1410712

I'm using fancybox for modals in my web application.

There are cases when I'd like to popup a 2nd fancybox while one is already opened. Does anyone know of a way to do this? I'm ok with one opening after the other closes, or both being open at the same time one underneath the other.

Again, i'm using jquery and fancybox in my application.

I'm using fancybox for modals in my web application.

There are cases when I'd like to popup a 2nd fancybox while one is already opened. Does anyone know of a way to do this? I'm ok with one opening after the other closes, or both being open at the same time one underneath the other.

Again, i'm using jquery and fancybox in my application.

Share Improve this question asked Mar 24, 2011 at 15:45 silksilk 5021 gold badge6 silver badges14 bronze badges 2
  • If your not tied down to Fancybox in particular highslide. this one does that job by default. Try opening several on the homepage – Dan Hanly Commented Mar 24, 2011 at 15:52
  • Highslide does look to be nice, but I'm trying to keep this free. It does however do what i'm needing. – silk Commented Mar 24, 2011 at 16:15
Add a ment  | 

2 Answers 2

Reset to default 5

Here is a good relevant thread discussing the same thing.. How do I open one Fancybox after another closes?

EDITED: In the discussion, there is a good example provided by https://stackoverflow./users/139396/o-k-w

I have placed the example on jsfiddle: http://jsfiddle/CkK8N/

I've just tackled this problem myself.

Scenario:

  • Launching one fancybox using an iframe
  • From the opened fancybox, open another fancybox with content delivered by an ajax webservice.

Key points

  • If using fancybox and iframes, you need to use parent.$.fancybox, otherwise $.fancybox will do.
  • Don't forget to show activity before loading content
  • Don't forget to resize after loading the content

Code snippet:

        if (parent) {
        // if in an iframe we need to show activity for the parents' fancybox
        parent.$.fancybox.showActivity();
    }
    else {
        // otherwise show activity for the fancybox of the current window
        $.fancybox.showActivity();
    }       

            // I'm using Ajax to fetch the content but you can fetch it in other ways too
    $.ajax({
        url: "your url goes here",
        type: "POST",
        contenttype: "text/xml; charset=utf-8",
        dataType: "xml",
        data: { "name": "john"},
        success: function (data, textStatus, jqXHR) {

            if (parent) {                   
                // if in an iframe we need to push the content into the parents' fancybox
                parent.$.fancybox($(jqXHR.responseXML).text());
                parent.$.fancybox.resize();
            }
            else {
                // otherwise push the content into the fancybox of the current window
                $.fancybox($(jqXHR.responseXML).text());
                $.fancybox.resize();
            }

        }
    });

本文标签: javascriptHow do I chain multiple jquery fancyboxesStack Overflow