Connect only once wizard dialog to keydown

update is called on each state so it binds multiple times to keydown and call
multiple times response with end state. This results in trying to delete
multiple times the same wizard session which fails.

issue8179
review60591002
This commit is contained in:
Cédric Krier committed 2019-03-15 11:18:14 +01:00
1 parent ebe1ab5340
commit 495dc7a5ef
1 file changed
+8 -8
+8 -8
View File
@@ -235,6 +235,14 @@
this.dialog = dialog.modal;
this.content = dialog.content;
this.footer = dialog.footer;
this.dialog.on('keydown', function(e) {
if (e.which == Sao.common.ESC_KEYCODE) {
e.preventDefault();
if (this.end_state in this.states) {
this.response(this.end_state);
}
}
}.bind(this));
dialog.body.append(this.widget).append(this.info_bar.el);
},
clean: function() {
@@ -262,14 +270,6 @@
update: function(view, buttons) {
this.content.unbind('submit');
Sao.Wizard.Dialog._super.update.call(this, view, buttons);
this.dialog.on('keydown', function(e) {
if (e.which == Sao.common.ESC_KEYCODE) {
e.preventDefault();
if (this.end_state in this.states) {
this.response(this.end_state);
}
}
}.bind(this));
this.show();
},
destroy: function(action) {