0
1 答案
0
最佳答案
I figured out: selector is not enough to make publicWidget work on website.
It just create an istance of the widget for each element matched by the selector but then you need to render the widget to make use of it. One way to achieve this task is by using the following code to initialize, render, and put the widget in the DOM:
* var myWidget = new MyWidget(this);
* myWidget.appendTo($(".some-div"));
The following snippet works well in the website
odoo.define("idro_portal.my_account_extend", function (require) {
"use strict";
var core = require('web.core');
var publicWidget = require('web.public.widget');
publicWidget.registry.PublicWidgetMyAccountExtend = publicWidget.Widget.extend({
selector: '.custom_public_widget_extend',
start: function () {
var res = this._super.apply(this, arguments);
this.do_notify('Success', 'Widget start notify');
return res
},
});
var PublicWidgetMyAccountExtend = new publicWidget.registry.PublicWidgetMyAccountExtend(this);
PublicWidgetMyAccountExtend.appendTo($(".custom_public_widget_extend"));
return publicWidget.registry.PublicWidgetMyAccountExtend;
});