-
-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Description
{{ stimulus_controller() }} is a great way to assign values to controller but targets and actions requires fallback to long syntax.
Can we have something like this:
<div {{ stimulus_controller('pages/reports/table') }}>
<a {{ stimulus_action('pages/reports/table', 'onClick') }}>Click me</a>
<span {{ stimulus_target('pages/reports/table', 'results') }}>results here</span>
</div>Otherwise, we have to write something like this:
<div {{ stimulus_controller('pages/reports/table') }}>
<a data-action="pages--reports--table#onClick">Click me</a>
<span data-pages--reports--table-target="results">results here</span>
</div>which is harder to write. Having those 2 extensions would also allow easier moving/renaming controllers; users would only need to find 'pages/reports/table' and replace with 'pages/zones/table-advanced'.
{{ stimulus_action('pages/reports/table', 'onClick') }} would also allow third parameter when non-default event is used:
<a {{ stimulus_action('pages/reports/table', 'onNonDefaultEvent', 'hover') }}>Hover me</a>which would generate
<a data-action="hover->pages--reports--table#onNonDefaultEvent">Hover me</a>Metadata
Metadata
Assignees
Labels
No labels