Similarly to the following question:
Trigger events via HTML element
I want to have two elements in my custom HTML component which have the data-click-target
attribute. How can I differentiate between them so I can trigger events based on that?
For instance; data-click-target="primary"
and data-click-target="secondary"
.
How can I trigger utils.confetti()
for the primary
value and fetchData.trigger()
for secondary
?
Basic example:
<div ... data-click-target="primary">
Confetti
</div>
<div ... data-click-target="secondary">
fetchData
</div>
At the moment, they both trigger the same events (plural).
Clicking 'Confetti' triggers:
utils.confetti();
getSite.trigger();
Clicking 'fetchData' triggers:
utils.confetti();
getSite.trigger();
Which isn't what I wanted.
How can I separate these two events?