diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-02-20 11:18:54 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-03-20 16:17:05 +0100 |
| commit | db592efca282d12f6fcef38a13dc2cbff31522b8 (patch) | |
| tree | 1fe40b8d522c825d7ded72d9d15394ae8050081f /addons/web/static/src/js/framework/widget.js | |
| parent | 180115665e2ff4447c0fc499a8dd18edab84e80c (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src/js/framework/widget.js')
| -rw-r--r-- | addons/web/static/src/js/framework/widget.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/addons/web/static/src/js/framework/widget.js b/addons/web/static/src/js/framework/widget.js index aae0ed36c19..ad68f4e9410 100644 --- a/addons/web/static/src/js/framework/widget.js +++ b/addons/web/static/src/js/framework/widget.js @@ -96,6 +96,16 @@ var Widget = core.Class.extend(mixins.PropertiesMixin, { 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. */ destroy: function() { @@ -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 |
