Ability to use action options without controller?
mockdeep opened this issue · comments
We have situations where we might need to capture an event and stop propagation. Is there any way to use an action option without needing to add a controller? For example, I'm imagining being able to do something like:
<div data-action="click->:stop"></div>
Is this possible?
I don't think this would be possible without a large change the the codebase. Actions are very much tied into the controller instance.
Maybe you could just make a simple controller to help for this case.
class UtilController extends Controller {
x() {
// does nothing
}
}
Stimulus.register('x', UtilController);
<div data-controller="x" data-action="click->x#x:stop"></div>
A reminder that elements can support multiple controllers by space seperated identifiers.
<input data-controller="x my-widget" data-action="click->x#x:stop focus->my-widget#expand" />