javascript - 如何订阅 CustomBox 模态关闭事件
问题描述
我已经实现了一个模式。我目前正在使用在此处找到的 FadeIn 模态https://htmlstream.com/preview/unify-v2.5.1/unify-main/shortcodes/shortcode-base-modals.html从查看使用此处的 CustomBox 的代码http: //dixso.github.io/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的关闭事件?
解决方案
我不熟悉您正在使用的库,但您可以将 JavaScript 函数调用添加到onclick
关闭按钮中定义的
<button type="button" class="close" onclick="Custombox.modal.close(); someCloseCallback();">
推荐阅读
- typescript - 在 TypeScript 中将变量定义为可区分联合的一种变体
- c# - Xamarin 表单中 ListView 的行为中缺少某些内容
- ms-access - MS Access(开关功能)
- assembly - 尔湾 x86 汇编输出
- java - Java 十六进制 velue 转换为 ascii 并返回十六进制出错
- java - 使用 java 处理 wsdl 模式中的“任何”字段
- marklogic - 在 Marklogic 9 中更新 MarkLogic 8 摄取的双时态文档
- angular - 组件是2个模块声明的一部分:AppModule
- javascript - 如何在 JS 中键入建议功能时触发搜索?
- asp.net-core - SignalR 干扰另一个控制器