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

Good morning. I see in almost all the odoo JS code this pair of variables, this.$el and this.$target, but I can't find any information about them.

Can someone explain me where should I use them and what they are used for? Where I cand find more info?

Thanks a lot. Regards


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

Hello Manuel,

You're right, official Odoo documentation doesn't explicitly define 'this.$el' and 'this.$target' in the context of Odoo widgets. However, based on common Javascript practices and Odoo's codebase, here's what they likely represent:

* this.$el:

This refers to the DOM element that the current Odoo widget instance represents.

In simpler terms, it's the HTML element in your Odoo view that the Javascript code is attached to.

You can use 'this.$el' to manipulate the DOM structure of that specific element.

* this.$target

This usage is less common and might depend on the specific widget you're working with.

In some cases, 'this.$target' might refer to a specific element within the widget's template (the HTML code defining the widget's structure).

It could also be related to the target element for an action triggered by the widget.

While there's no dedicated documentation for these specific variables, you can browse Odoo's actual Javascript code for widgets to see how they use this.$el and this.$target. Look for files with .js extension in the relevant Odoo module directory.


Hope it helps.

Ảnh đại diện
Huỷ bỏ
Tác giả

Of course it helps. Thanks a lot!

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 24
1182
2
thg 4 23
4265
0
thg 3 22
2690
1
thg 3 22
2050
1
thg 10 20
1125