I want to use custom events in my J-Query website. Now I'm not sure which one is the best way to trigger a custom event on all elements attached to this event.
An example could be more clarifying here: Basically I could use
$('#id').trigger('customevent');
I don't want the triggering element to have to know all elements attached to the event. So I could use
$('*').trigger('customevent');
which would hopefully do what I want. But I'm afraid that this way has some performance issues.
Another way I was thinking about is using a class. All elements attached to the event could add this class to themselves. Then I can use this class as selector. However, all this smells like workaround.
I really hope that somebody knows an usual way to solve my problem.
Just found the answer by myself (which is now deprecated, see comment below):
$.event.trigger('customevent');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With