我刚刚意识到事件 show.bs.modal 不仅在显示模态本身时被触发,而且在每次为模态内的元素调用 .show() 方法时才会触发。
事件处理程序以下列方式附加:
$('#modalName').on('show.bs.modal', function(event) { ... });
关于如何确保此处理程序中的代码仅在 modal show 上触发的任何想法?
尤其是当您在模式中使用 formValidator.io 时会出现问题(一旦表单字段验证失败,它会为元素调用 .show() )