summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2015-08-31 10:56:13 +0200
committerAaron Bohy <aab@odoo.com>2015-09-01 20:05:34 +0200
commit294abae96874465cdc147e6d227ed17597f7e4d6 (patch)
tree12f8ae767988d1f98b670429ce3257c779d1279a /addons/web/static/src/js/framework
parentac39b03a24ceca2f96e5bf0c3a61c596744b6c0a (diff)
[IMP] web: dialog: wait for button's onclick handler to close
When a button in the modal's footer has an onclick handler and closes the modal, the action of closing the modal should wait for the potential deferred returned by the handler. For instance, if an handler performs an asynchronous call and, when resolved, triggers a notification, the notification doesn't reach the webclient if the modal is already closed because the widgets hierarchy is broken.
Diffstat (limited to 'addons/web/static/src/js/framework')
-rw-r--r--addons/web/static/src/js/framework/dialog.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/web/static/src/js/framework/dialog.js b/addons/web/static/src/js/framework/dialog.js
index 1aedec82aff..b5e63834614 100644
--- a/addons/web/static/src/js/framework/dialog.js
+++ b/addons/web/static/src/js/framework/dialog.js
@@ -82,11 +82,12 @@ var Dialog = Widget.extend({
var $b = $(QWeb.render('WidgetButton', { widget : { string: text, node: { attrs: {'class': classes} }}}));
$b.prop('disabled', b.disabled);
$b.on('click', function(e) {
+ var click_def;
if(b.click) {
- b.click.call(self, e);
+ click_def = b.click.call(self, e);
}
if(b.close) {
- self.close();
+ $.when(click_def).always(self.close.bind(self));
}
});
self.$footer.append($b);