我在项目中使用的是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>
答案 0 :(得分:1)
您可以在click
( IE 的安全方法)的document
上尝试此操作,调用$.modal.close()
函数:
$(document).on('click', function(){
if($('#osx-modal-content').is(':visible')){
$.modal.close()
}
});