Stimulus: On Change event

Created on 2 Jan 2018  路  4Comments  路  Source: hotwired/stimulus

Right now when you want to fire an action on change->
The event will be fired only when u change focus from input field itself.

<inpit type="text" data-action="change->controller#change_value" />

Should it work like that?
I thought it should fire an action on every input value change.

Most helpful comment

I thought it should fire an action on every input value change.

I think you can do it using the keypress event 馃憤

All 4 comments

Browsers only dispatch the change event when a change is committed (e.g. when a text input is blurred):

The change event is fired for <input>, <select>, and <textarea> elements when a change to the element's value is committed by the user. Unlike the input event, the change event is not necessarily fired for each change to an element's value.

Got it. Thank you! @georgeclaghorn

I thought it should fire an action on every input value change.

I think you can do it using the keypress event 馃憤

I think you can do it using the keypress event +1

keypress does not work for backspace in Firefox for me. I use keyup event.

Was this page helpful?
0 / 5 - 0 ratings