How to dispatch events to specific component id? Currently I have the target component id, and I can dispatch event to it e.g, ->dispatch('set-value-'.$this->dispatchToId), but I can't listen to that event specifically in target component.
I've read Listening for dynamic event names in livewire docs but It can't do that:
#[On('set-values-{__id}')] // ERROR: Unable to evaluate dynamic event name placeholder: {__id}
public function setValues() {}}
@Sinnbeck The problem is, when I try to generate dynamic listen names like: #[On('set-values-{__id}')] livewire throws exception: Unable to evaluate dynamic event name placeholder: {__id}
@amir5 Yes you said that already but without seeing the component I cannot see the issue. I guess you forgot to add the property as @tykus suggested, but its impossible to know without seeing your code..
@amir5 Well that obviously does not work. But I assume you are passing in the ID or the model that you can use instead? :) The __ most likely refers to it being an internal value
@amir5 then find some other property to target the Component; like @sinnbeck says, we're seeing only a snippet of your work and cannot guess at what you are working with.