Using the action helper works fine inside a DOM element:
<input value="123" {{action "someAction" on="click"}}
But then let's say you are using the input helper to generate your input field:
{{input value=123}}
And you want to stick the very same action onto this input helper..
The docs say:
" To dispatch an action on specific events, such as enter or key-press, use the following
{{input value=123 key-press="updateFirstName"}} "
And yet..
This code does nothing:
{{input type="text" value=123 click="someAction"}}
I also tried this:
{{input type="text" value=123 action="someAction" on="click"}}
I'm slowly going insane. Can someone point me to the correct way of using actions inside the Ember input helper?
Thanks!
{{input value=123 key-press="updateFirstName"}}
The above code will work fine. make sure updateFirstName is in the required context like if its in template then it should be present in controller or if its in component then it should be present in component.js file.
For click handler, you can try like the below.
{{input value=appName click=(action "onClick")}}
You can have look at this twiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With