Scope events to specific components
3.xBy default, emitted events are sent to all components on the page. You can restrict the scope of an event using the following methods:
- Emit only to Parent Components: Use
emitUp()in PHP ordata-action="live#emitUp"in Twig. - Emit only to Yourself: Use
emitSelf()in PHP ordata-action="live#emitSelf"in Twig. - Emit only to a Specific Component Name:
- PHP:
$this->emit('eventName', componentName: 'ComponentName'). - Twig: Use the
name()modifier in the event parameter:data-live-event-param="name(ComponentName)|eventName".
- PHP: