[ADD] Web: openerpframework.js: willStart() function

Add the willStart() function to Widgets. This function is executed
between init() and start() and its purpose is to perform various
asynchronous calls required for start() to be executed.

It is automatically called after rendering a Widget, and start() is
called once the Deferred returned by willStart() is resolved.
This commit is contained in:
Aaron Bohy
2015-03-20 16:17:05 +01:00
parent 180115665e
commit db592efca2
+16 -3
View File
@@ -95,6 +95,16 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, {
// FIXME: this should not be
this.setElement(this._make_descriptive());
},
/**
* Method called between init and start. Performs asynchronous calls required by start.
*
* This method should return a Deferred which is resolved when start can be executed.
*
* @return {jQuery.Deferred}
*/
willStart: function() {
return $.when();
},
/**
* Destroys the current widget, also destroys all its children before destroying itself.
*/
@@ -162,9 +172,12 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, {
}, this), target);
},
__widgetRenderAndInsert: function(insertion, target) {
this.renderElement();
insertion(target);
return this.start();
var self = this;
return this.willStart().then(function() {
self.renderElement();
insertion(target);
return self.start();
});
},
/**
* Method called after rendering. Mostly used to bind actions, perform asynchronous