跳至内容
菜单
此问题已终结
1 回复
3955 查看

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?

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
2
9月 23
8791
1
12月 22
3458
3
3月 25
7184
0
1月 24
1327
1
10月 23
3637