Subclassing widget is most important for Odoo.With the help of subclassing Widget() we can change the standard manner with the extend() method, and provides a number of abstract properties and concrete methods .Subclassing Widget looks like this:
var MyWidget = Widget.extend({
// QWeb template to use when rendering the object
template: "MyQWebTemplate",
events: {
// events binding example
'click .my-button': 'handle_click',
},
init: function(parent) {
this._super(parent);
// insert code to execute before rendering, for object
// initialization
},
start: function() {
var sup = this._super();
// post-rendering initialization code, at this point
// allows multiplexing deferred objects
return $.when(
// propagate asynchronous signal from parent class
sup,
// return own's asynchronous signal
this.rpc(/* */))
}
});
Note-you will have to first call render() on the widget, then insert it into your Subclassing Widget and start it.
0 Comment(s)