如何订阅CustomBox Modal关闭事件

时间:2018-07-31 21:48:02

标签: javascript html

我执行了一个模式。我目前正在使用此处https://htmlstream.com/preview/unify-v2.5.1/unify-main/shortcodes/shortcode-base-modals.html的FadeIn模态。通过查看代码,它利用此处http://dixso.github.io/custombox/

的CustomBox
<a class="btn u-btn-primary" href="#modal1" data-modal-target="#modal1" data-modal-effect="fadein">Launch Modal
</a>

<!-- Demo modal window -->
<div id="modal1" class="text-left g-max-width-600 g-bg-white g-overflow-y-auto g-pa-20" style="display: none;">
  <button type="button" class="close" onclick="Custombox.modal.close();">
    <i class="hs-icon hs-icon-close"></i>
  </button>
  <h4 class="g-mb-20">Modal title</h4>
  <p>Modal Body</p>
</div>
<!-- End Demo modal window -->

我可以看到CustomBox的事件类型为Closed,但是我不确定如何正确订阅该事件。我添加了以下代码,但没有任何反应。模态关闭后。

document.addEventListener('custombox.close', function() {

});

请问我如何正确订阅CustomBox的关闭事件?

1 个答案:

答案 0 :(得分:0)

我对您所使用的库不熟悉,但是您可以将JavaScript函数调用添加到关闭按钮中定义的onclick

<button type="button" class="close" onclick="Custombox.modal.close(); someCloseCallback();">
相关问题