Using Fancybox version 2 - When Closing 2nd fancybox reopen first fancybox instead of simply closing

后端 未结 1 665
小鲜肉
小鲜肉 2021-01-16 03:40

Using Fancybox version 2 supplied by http://fancyapps.com/fancybox/#support

I want to open a fancybox from my main page, but within that 1st fancy box a second fancy

相关标签:
1条回答
  • 2021-01-16 04:36

    You could create two scripts, one for each link so in the main page you have:

    <a href="1stFancyBox.html" class="fancybox1 fancybox.ajax">1st Fancy Box</a>
    

    Notice that class is now fancybox1 ... then the script tha fires the first fancybox.

    $(".fancybox1").fancybox();
    

    Inside 1stFancyBox.html you can have this link

    <a href="2ndFancyBox.html" class="fancybox2 fancybox.ajax">2nd FancyBox</a>
    

    Notice that class is now fancybox2

    Also in the main page add the script that fires the second fancybox (from within the first fancybox):

    $(".fancybox2").fancybox({
     afterClose: function(){
      $(".fancybox1").trigger("click");
     }
    });
    

    The script above will fire the first fancybox after closing the second fancybox regardless the content of 2ndFancyBox.html.

    UPDATE: I added a DEMO here

    0 讨论(0)
提交回复
热议问题