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

I want to trigger a JS event from another JS function from a different file. I want to apply a discount from customer card when user will set a customer in POS. I already made a JS function which is working perfectly but its need to set customer first then needs to click another button but I want to apply this when customer will set. Is there any way to trigger event from another class function?

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

Hi,

Try like following.

 // Import this in both files
const { posbus } = require("point_of_sale.utils");

// use this inside the function where you need to trigger the action
posbus.trigger('a-unique-custom-name');

// Import this in the file where you want to receive the action
const { useBus } = require("@web/core/utils/hooks");

// Add this to the setup function of your component
useBus(posbus, 'a-unique-custom-name', this.functionName);

// define your function

Regards

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 23
9161
1
thg 12 22
3657
3
thg 3 25
7769
0
thg 1 24
1456
1
thg 10 23
3836