1

我在一个项目中使用 simplemodal OSX,我希望当用户在弹出窗口之外单击时关闭模式弹出窗口。我使用以下代码将overlayClose 设置为true,但这不起作用。X 按钮可以正常工作,但在外部单击时则不行;

    $("#osx-modal-content").modal({
                autoPosition: true,
                autoResize: false,
                overlayId: 'osx-overlay',
                containerId: 'simplemodal-container',
                closeHTML: null,
                closeByEscape: true,
                setEvent: 'click',
                closeByDocument: true,
                overlayClass: '',
                minHeight: 80,
                opacity: 65, 
                position: ['72px',],
                overlayClose: true,
                onOpen: OSX.open,
                onClose:OSX.close

            });

更新:添加了 HTML

<!-- modal content -->
<div id="osx-modal-content">

    <div id="osx-modal-data">

        <div id="simplemodal-container" class="simplemodal-container">
            <div id="modal-placeholder" class="simplemodal-data" style="display: block;">


            </div>

        </div>

    </div>
</div>
4

1 回答 1

2

你可以试试这个,在clickdocumentIE的安全方法)上,调用$.modal.close()函数:

$(document).on('click', function(){
   if($('#osx-modal-content').is(':visible')){
     $.modal.close()
   }
});
于 2013-06-27T12:38:17.310 回答