Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Fancybox 1.3.4-重新加载后无覆盖层_Javascript_Jquery_Jquery Plugins_Fancybox - Fatal编程技术网

Javascript Fancybox 1.3.4-重新加载后无覆盖层

Javascript Fancybox 1.3.4-重新加载后无覆盖层,javascript,jquery,jquery-plugins,fancybox,Javascript,Jquery,Jquery Plugins,Fancybox,我正在开发一个ajax弹出系统。功能之一是,当ajax收集任何新数据时,使用Fancybox显示它。有两种情况: 用户读取ajax带来的数据,并关闭fancybox 用户是AFK。当另一个数据进来时,它应该被附加到已经显示的fancybox内容上 fancybox的html容器如下所示: <div id="notifications_fancybox"> <div class="notifications_fancybox_title"> Powiadomie

我正在开发一个ajax弹出系统。功能之一是,当ajax收集任何新数据时,使用Fancybox显示它。有两种情况:

  • 用户读取ajax带来的数据,并关闭fancybox
  • 用户是AFK。当另一个数据进来时,它应该被附加到已经显示的fancybox内容上
  • fancybox的html容器如下所示:

    <div id="notifications_fancybox">
      <div class="notifications_fancybox_title">
        Powiadomienia
      </div>
      <div id="notifications_fancybox_content">
    
      </div>
    </div>
    
    如果已打开,请将其关闭:

    if(nl.isFancyboxOpened()){
        $.fancybox.close();
    }
    
    附加一些数据

    $('#otifications_fancybox_content').append('some html');
    
    打开fancybox

    nl.openFancybox = function(){   
        if(nl.isFancyboxOpened() == false){
          $.fancybox(
            $('#notifications_fancybox').html(),
            {
              'autoDimensions'            : false,
              'overlayShow'               : true,
              'hideOnOverlayClick'        : false,
              'showCloseButton'           : true,
              'width'                     : 450,
              'height'                    : 400,
              'transitionIn'              : 'none',
              'transitionOut'             : 'none'
            }
          );
    
        }
        else{
          $.fancybox.resize();
        }
    };
    
    现在,主要问题是: 当fancybox第一次显示时,一切都很好——有叠加、按钮等等


    当显示更多的ajax数据时,我尝试完成上面的过程(关闭-追加-重新打开),除了。。。没有覆盖层!所以用户可以点击页面上的所有内容,我不希望他这样做

    好的,我已经设法解决了这个问题。这不完全是我想要的,但我会做得很好的

    我的解决方案使用
    onComplete
    回调强制将覆盖的
    display
    属性设置为
    block
    。它被打包在
    setTimeout
    中,因为立即调用它是不起作用的。此外,将超时时间减少到特定时间以下将导致此解决方案失败。我相信有更好的方法解决这个问题,但我还没有找到一个。。。然而;)


    你能分享一个链接吗?不幸的是我不能-corpo内部网系统。好消息是我已经设法解决了这个问题。。。这不完全是我想要的,但效果很好。详情请参阅下一答复。
    nl.openFancybox = function(){   
        if(nl.isFancyboxOpened() == false){
          $.fancybox(
            $('#notifications_fancybox').html(),
            {
              'autoDimensions'            : false,
              'overlayShow'               : true,
              'hideOnOverlayClick'        : false,
              'showCloseButton'           : true,
              'width'                     : 450,
              'height'                    : 400,
              'transitionIn'              : 'none',
              'transitionOut'             : 'none'
            }
          );
    
        }
        else{
          $.fancybox.resize();
        }
    };
    
    $.fancybox(
            $('#notifications_fancybox').html(),
            {
              'autoDimensions'            : false,
              'overlayShow'               : true,
              'hideOnOverlayClick'        : false,
              'showCloseButton'           : true,
              'onComplete'                : function(){setTimeout(function(){$('#fancybox-overlay').css('display', 'block');}, 250);},
              'width'                     : 450,
              'height'                    : 400,
              'transitionIn'              : 'none',
              'transitionOut'             : 'none'
            }
    );