Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
5518 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
ago 23
194
1
feb 22
2987
4
dic 23
34449
7
dic 23
20133
0
ago 18
5939