Skip to content

Commit

Permalink
[DOC beta] Add common patterns for {{action (mut...
Browse files Browse the repository at this point in the history
Add two common patters for the `mut` helper used as parameter of
`action`.

Fixes #14525

(cherry picked from commit da63057)
  • Loading branch information
Serabe authored and chancancode committed Nov 28, 2016
1 parent ec51087 commit 98fb2de
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/ember-glimmer/lib/helpers/mut.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ import { INVOKE } from './action';
The `mut` helper changes the `totalClicks` value to what was provided as the action argument.
The `mut` helper, when used with `action`, will return a function that
sets the value passed to `mut` to its first argument. This works like any other
closure action and interacts with the other features `action` provides.
As an example, we can create a button that increments a value passing the value
directly to the `action`:
```handlebars
{{! inc helper is not provided by Ember }}
<button onclick={{action (mut count) (inc count)}}>
Increment count
</button>
```
You can also use the `value` option:
```handlebars
<input value={{name}} oninput={{action (mut name) value="target.value"}}>
```
@method mut
@param {Object} [attr] the "two-way" attribute that can be modified.
@for Ember.Templates.helpers
Expand Down

0 comments on commit 98fb2de

Please sign in to comment.