Search code examples
javascriptjquerymodal-dialogfancybox

jquery fancybox - prevent close on click outside of fancybox


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 outside of the fancybox modal window (grayed out area).

Is there a way to force the user to click the X or a button that I trigger the close event? This seems like it should be simple so I'm hoping I'm just reading the examples wrong.

I've tried hideOnContentClick: false but that doesn't seem to be working for me. Any ideas?


Solution

  • 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);