Add section about the value option of the action helper - #670
Conversation
There was a problem hiding this comment.
are you sure you're supposed to do value={{favoriteBand}}?
There was a problem hiding this comment.
Not totally, but I think it enables various things as the input value and the property (favoriteBand) are no longer two-way bound and thus you could do some filtering/transformation before you "write back" the value. This is silly but hopefully demonstrates my point:
actions: {
incRating(value) {
const newValue = window.parseInt(value) + 1;
this.set('rating', newValue);
}
}When you focus out of the text field, the number you inputted will be incremented by one.
There was a problem hiding this comment.
What do you mean they're no longer two-way bound? I think I'm missing something here.
There was a problem hiding this comment.
This is <input> with attribute bindings NOT {{input}}. Attribute bindings are one way ({{input}} gets around this by using the change event and updating the internal value).
There was a problem hiding this comment.
If you type something in the input box, rating does not get updated right away to the inputted value, only when you the input loses focus (in other words, when the action is fired). It is somewhat hard to get one's head around but maybe because we're too used to two-way bindings.
There was a problem hiding this comment.
@rwjblue So is the code example I gave demonstrative enough? I originally used oninput, not onblur but I guess both could work.
…ue-option Add section about the `value` option of the action helper
|
I'm convinced :P |
|
Thank you for merging, Ricardo. |
I took a stab of explaining what the
valueoption of the action helper is and what it is good for. Let me know if any corrections need to be made.