hotwired / stimulus

A modest JavaScript framework for the HTML you already have
https://stimulus.hotwired.dev/
MIT License
12.67k stars 420 forks source link

Multiple events to the same action #95

Closed kaspernj closed 6 years ago

kaspernj commented 6 years ago

I have an input text field, and I need to calculate a total when it is changed. I use the change and keyup events to do this. I couldn't find a way to bind multiple events to the same action.

If this indeed isn't possible, then I would suggest something like this:

<input type="text" data-action="(change,keyup)->controllerName#calculateTotal" />

I couldn't find anything on multiple different events on an element either? I would suggest something like this for it:

<input type="text" data-action-change="controllerName#calculateTotal" data-action-keyup="controllerName#keyUpPressed" />

Thank you for a great framework. This has really cleaned up my JavaScript.

mintyPT commented 6 years ago

Take a look: https://github.com/stimulusjs/stimulus/issues/52

kaspernj commented 6 years ago

@mintyPT That works. Thank you :-)