jquery fancybox - prevent close on click outside of fancybox

后端 未结 15 930
独厮守ぢ
独厮守ぢ 2020-12-16 18:15

I\'m using the Fancybox plugin for my modal windows. It seems like no matter what options I use I can\'t prevent the fancybox modal window from closing when the user clicks

相关标签:
15条回答
  • 2020-12-16 18:32

    Set the closeClick parameter to false inside your function:

    $(".video").click(function() {
        $.fancybox({
            width: 640,
            height: 385,
            helpers: { 
                overlay: {
                    closeClick: false
                }
            }
        });
    
        return false;
    });
    
    0 讨论(0)
  • 2020-12-16 18:33

    There is no option for that. You will have to change the source code.

    In jquery.fancybox-1.2.1.js you need to comment out (or delete) line 341 in the _finish method:

    //$("#fancy_overlay, #fancy_close").bind("click", $.fn.fancybox.close);
    
    0 讨论(0)
  • 2020-12-16 18:35

    For this issue, please try this way

    $("YourElement").fancybox({
     helpers: {
            overlay: { closeClick: false } //Disable click outside event
        }
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-16 18:37

    I ran into the same "issue". This worked for me:

    $("#fancybox-overlay").unbind();
    
    0 讨论(0)
  • 2020-12-16 18:37

    Just add following line to your function, you do not have to change anything in jquery.fancybox-1.2.6.js

    callbackOnStart : function() {$("#fancy_overlay").bind("click","null");},
    
    0 讨论(0)
  • 2020-12-16 18:38
    <script type="text/javascript">
      $(document).ready(function() {
        $("#your_link").fancybox({
          'hideOnOverlayClick':false,
          'hideOnContentClick':false
        });
      });
    </script>                              
    
    0 讨论(0)
提交回复
热议问题