disable closing popup when clicking on background

…衆ロ難τιáo~ 提交于 2019-12-11 21:04:26

问题


I use featherlight.js for lightbox. When it is opened and I click on it's background it cloeses popup. I need to disable this functionality. I noticed that this js has closeTrigger option in it but don't know how to use it.


回答1:


There is a default option in it:

 closeOnClick: false           /* Close lightbox on click ('background', 'anywhere', or false) */

Select "FALSE" value this will disable the closing of popup on clicking on background.




回答2:


I would suggest not to write javascript snippet separately as you already using "data" attributes to initialise the lightbox.

As per documentation provided, you can set data-featherlight-close-on-click="false" in markup itself to achieve the same.

Fiddle - http://jsfiddle.net/ylokesh/c5pq5bs1/2/

HTML

<a class="btn btn-default" href="#" data-featherlight-close-on-click="false" data-featherlight="#fl1">Default</a>
<div class="lightbox" id="fl1">
    <h2>Featherlight Default</h2>
    <p>
        This is a default featherlight lightbox.<br>
        It's flexible in height and width.<br>
        Everything that is used to display and style the box can be found in the 
    </p>
    <a href="https://github.com/noelboss/featherlight/blob/master/src/featherlight.css">featherlight.css</a> file which is pretty simple.
</div> 

With this option, you will save writing separate script block just to enable this feature.




回答3:


In documentation, you can disable it from its defaults

defaults: {
      closeOnClick: false, /* Close lightbox on click ('background', 'anywhere', or false) */
}



回答4:


thanks, I found solution after writing my question, but thanks everyone. My final code looks in this way:

jQuery.featherlight(jQuery('#professional_investor_box'), {
        closeOnClick:false,
});


来源:https://stackoverflow.com/questions/30938584/disable-closing-popup-when-clicking-on-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!