【发布时间】:2015-05-13 19:10:02
【问题描述】:
使用引导模式,我想为模式和此模式内的以下提交按钮注册一个事件处理程序。
随后调用 modal 并关闭 ist 会导致多次执行 #modalSubmitButton 事件。你能想出任何解决方案来防止这种行为并且只在实际事件上触发,而忽略之前对 modal 的调用吗?我嵌套处理程序的方法可能是错误的吗?
我已经尝试过event.stopPropagation/event.unbind()等的所有组合。
$(document).on('click', '#myModalID' function () {
// i fetch some data from the clicked element here
// and make it accessible to the subsequent eventHandler
$(document).on('click', '#modalSubmitButton' function () {
// eventually calling service on click of button
invokeService()
});
});
【问题讨论】:
标签: jquery twitter-bootstrap modal-dialog nested propagation