Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5483 Zobrazení

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.

Avatar
Zrušit
Autor Nejlepší odpověď

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!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
srp 23
194
1
úno 22
2977
4
pro 23
34412
7
pro 23
20105
0
srp 18
5913