jquery fancybox - prevent close on click outside of fancybox

后端 未结 15 990
独厮守ぢ
独厮守ぢ 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:47

    I had to use a combination of all of the above answers, as all of them include errors. Certainly, no editing of the source code is necessary.

    In my case, I wanted to disable overlay clicks closing the box as I had a progression of questions that would be displayed sequentially inside the fancybox, so I didn't want users to lose their progress by accidentally clicking on the overlay, but wanted to keep that functionality elsewhere on the page.

    Use this to disable it:

    $(".fancybox-overlay").unbind();
    

    Use this to re-enable it:

    $(".fancybox-overlay").bind("click", $.fancybox.close);
    

提交回复
热议问题