我有一个模态,在角落有一个x来关闭它,但我只能关闭它一次。这是流程:
点击按钮打开模态
点击x关闭模态
点击按钮再次打开模态
点击x关闭模态(没有任何反应)
close函数中的log语句第一次运行但不是第二次运行。我在这里缺少什么?
var myModal = Marionette.View.extend({
initialize: function() {
_.bindAll(
this,
"close",
"open",
"submit",
);
this.closeEl = this.$el.find(".close");
this.submitEl = this.$el.find(".submit");
this.formEl = this.$el.find(".form");
this.closeEl.click(this.close);
this.submitEl.click(this.submit);
this.triggerEl.click(this.open);
},
close: function() {
console.log("close");
Modal.close();
},
open: function(event) {
event.preventDefault();
Modal.open({
content: this.$el,
overlayClosesOnClick: false
});
},
submit: function(event) {
event.preventDefault();
// do stuff
}
});