As documented in http://emberjs.com/api/classes/Ember.Templates.helpers.html#method_get, it should be possible to use the mut
helper within the action
helper to update a property as follows:
<!-- factName is set to "height" and should be changed to "weight" -->
<button {{action (mut factName) "weight"}}>Show weight</button>
However, instead of updating factName
, Ember tries to invoke an action named after the current value of factName
:
error Script error. (line 0)
ember.debug.js:44562 Uncaught Error: Nothing handled the action 'height'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.
I do not know if this is a bug or if the mut
helper was never intended to work that way.
Test case: http://emberjs.jsbin.com/radogusojex
I do not think the element space action syntax allows this, you may have to use closure actions for this behavior:
<button onclick={{action (mut factName) "weight"}}>Show weight</button>
Well, in that case the documentation should reflect that.
Sorry for being too abrupt before, I was talking about the implementation (not what we actually want to support). I think that special casing (mut helper as is done elsewhere in the system seems perfectly fine.
We do need to decide a bit more wholistically what we intend as the element space actuon's fate...
In addition to the solution put forward by @rwjblue, another way to solve it is:
<button {{action (action mut factName) "weight")}}>Show weight</button>
I have edited your JS Bin to demonstrate it: http://emberjs.jsbin.com/qavaki/1
Most helpful comment
In addition to the solution put forward by @rwjblue, another way to solve it is:
I have edited your JS Bin to demonstrate it: http://emberjs.jsbin.com/qavaki/1