Possibility to target a composant instance by its id when emitting an event #2864
Replies: 3 comments
-
How would you do this in Javascript & DOM Events ? Or in PHP / Symfony with EventDispatcher ? |
Beta Was this translation helpful? Give feedback.
-
According to what i had understood about the way it works :
Here is a basic example of usage ; Example : (on the php side)
My way to do it for now
|
Beta Was this translation helpful? Give feedback.
-
To be honest my question was more "how would you do this if you were not using LiveComponent?" Because event very rarely allow a recipient... To me, the second we start targetting a specific instance, it's not an event but a message/command 🤷 But this is a feature that would please more than one person, so :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I was wondering it there was a specific reason to not be able to target a specific composant instance when emitting an event.
why does i need this ?
Targetting a component by its name made all instances be notified of an event ;
Sometimes, i just want to notify the first parent or a specific component instance (when many component of same class are present in the page).
Also, it can avoid many unneccessary XHR requests when an event is emitted.
I had modify the live_controller.js to handle the case of the component name parameter is looking like #componentId but i was wondering if there was a specific reason to not have this feature from the start.
Beta Was this translation helpful? Give feedback.
All reactions