我从某处借用此代码以从一个引导模式切换到另一个模式。切换后,我想关闭处理程序,以便每次只关闭第一个模式时都不会切换。我的问题是,一旦使用了模式切换功能,我不知道如何关闭特定事件处理程序,而不关闭在特定模式关闭时执行的其他事件(在其他位置完成)时如何关闭。有什么建议么?使用jquery删除一个事件处理程序“.off”
//switch modals
function switchModals(fromModal, toModal) {
$(fromModal).on('hidden.bs.modal', function (e) {
$(toModal).modal('show');
//clear this function so it doesn't show up if they exit the window again
$(fromModal).off('hidden.bs.modal');
});
$(fromModal).modal('hide');
}
这没有奏效。我认为它需要在.off()的某处指定,但我不知道如何。 – Quin
你可以发布你的完整代码,或链接到你的网页? –