Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5459 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 8 23
194
1
thg 2 22
2973
4
thg 12 23
34403
7
thg 12 23
20100
0
thg 8 18
5908