Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
5453 Переглядів

Hi,

Consider the below class exists

local.MyWidget = instance.Widget.extend({
events: {
"click .my_button": "button_clicked",
},
button_clicked: function() {
console.log("Button Clicked");
}
});


I want to add one more event to the variable like below

 local.MyWidget = instance.Widget.extend({
events: {
"click .my_button": "button_clicked",
},
button_clicked: function() {
console.log("Button Clicked");
}
});

   
The above doesn't work and the error i get is "events is undefined". Kindly let me know how this can be done in odoo. Thanks a lot.

Аватар
Відмінити
Автор Найкраща відповідь

The below works for me.

MyWidget.include({
    init: function(parent, options) {
        this.events["click .new_button"] = "new_button_clicked";
        this._super(parent, options);
    },

    new_button_clicked: function() {
        console.log("New Button Clicked.");
    } 
});

Cheers!

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
серп. 23
194
1
лют. 22
2965
4
груд. 23
34391
7
груд. 23
20067
0
серп. 18
5901