[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.
This commit is contained in:
Aaron Bohy
2015-09-01 20:05:34 +02:00
parent ac39b03a24
commit 294abae968
+3 -2
View File
@@ -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);