Visible inline div disappears after being displayed with fancyBox

后端 未结 3 382
谎友^
谎友^ 2021-01-18 10:17

I am posting a problem and solution here to help anyone who has experienced the same problem as me.

I have a

on my page which I wanted to al
3条回答
  •  离开以前
    2021-01-18 10:38

    I wrote that solution for fancybox v2.0.6 and below (I am JFKDIAZ too ;). That issue has been fixed with the new release v2.1.x + (a temporary placeholder has been set to return the content to its original place), however the NEW issue with v2.1.x + (v2.1.2 to date) is that the content is indeed properly returned but hidden.

    The new workaround (for version 2.1.x +) would be just to make it visible afterClose like

    var tarGet; // initialize var at top of script
    

    the callbacks

    beforeShow: function(){
     tarGet= this.href;
    },
    afterClose: function(){
     $(tarGet).show();
    }
    

    see forked fiddle


    EDIT (March 27, 2014) : To avoid global variables as pointed out by @Henrik-Erlandsson in his answer, you could simply do :

    afterClose: function(){
      $(this.href).show();
    }
    

    See forked JSFIDDLE

提交回复
热议问题