Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
3915 Weergaven

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?

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
2
sep. 23
8755
1
dec. 22
3444
3
mrt. 25
7124
0
jan. 24
1306
1
okt. 23
3632