Zurb Foundation Reveal Modal - preventing close on background click

会有一股神秘感。 提交于 2019-12-03 05:07:51

If you set the closeOnBackgroundClick option to false then your modal won't close when you click in the background.

<div class="reveal-modal" data-options="closeOnBackgroundClick:false">

Yehhhhh Finally Found It:

Put below code on your foundation reveal model. Than it not close by clicking on background or by pressing esc key.

data-options="close_on_background_click:false;close_on_esc:false;"

Ex:

<div id="AccessContainer" class="reveal-modal" data-reveal data-options="close_on_background_click:false;close_on_esc:false;">
</div>

For anyone looking at this question in 2018, I'm using Version 6.4.0 and this works:

data-close-on-click="false" data-close-on-esc="false"

I added that to the reveal div like this and it's working (as of July 2018):

<div class="reveal" id="modalVideo" data-reveal data-close-on-click="false" data-close-on-esc="false"> 

You can achieve this globally by executing the following line of JavaScript before showing any modals:

Foundation.libs.reveal.settings.close_on_background_click = false;

For latest version of foundation by zurb use following snippet

<div id="myModal" class="reveal-modal"  data-options="close_on_background_click:false" data-reveal>

Complete Code will look like

<a href="#" data-reveal-id="myModal" id="dd">Click Me For A Modal</a>
<div id="myModal" class="reveal-modal"  data-options="close_on_background_click:false" data-reveal>
    <h2>Awesome. I have it.</h2>
<p class="lead">Your couch.  It is mine.</p>
<p>I'm a cool paragraph that lives inside of an even cooler modal. Wins!</p>
<a class="close-reveal-modal">&#215;</a>
</div>

If using the stand-alone Reveal plugin here: https://zurb.com/playground/reveal-modal-plugin

Use the following on the link that opens the modal.

<a href="#" data-reveal-id="myModal" data-closeonbackgroundclick="false">Open Modal</a>

This answer applies to Foundation 6. Below are the correct option for both preventing close on background click (closeOnClick:false;) and preventing close via the Esc key (closeOnEsc:false;).

<div class="reveal" id="exampleModal1" data-reveal
    data-options="closeOnClick:false; closeOnEsc:false;">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!