http://emberjs.com/api/classes/Ember.Templates.helpers.html#method_get ์ ์ค๋ช
๋ ๋๋ก mut
๋์ฐ๋ฏธ ๋ด์์ action
mut
action
๋์ฐ๋ฏธ๋ฅผ ์ฌ์ฉํ์ฌ ์
๋ฐ์ดํธํ ์ ์์ด์ผ ํฉ๋๋ค. ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
<!-- factName is set to "height" and should be changed to "weight" -->
<button {{action (mut factName) "weight"}}>Show weight</button>
๊ทธ๋ฌ๋ factName
๋ฅผ ์
๋ฐ์ดํธํ๋ ๋์ Ember๋ 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.
์ด๊ฒ์ด ๋ฒ๊ทธ์ธ์ง ์๋๋ฉด mut
๋์ฐ๋ฏธ๊ฐ ๊ทธ๋ฐ ์์ผ๋ก ์๋ํ๋๋ก ์๋๋ ์ ์ด ์๋์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
ํ ์คํธ ์ผ์ด์ค: http://emberjs.jsbin.com/radogusojex
์์ ๊ณต๊ฐ ์์ ๊ตฌ๋ฌธ์ด ์ด๋ฅผ ํ์ฉํ์ง ์๋๋ค๊ณ ์๊ฐํฉ๋๋ค. ์ด ๋์์ ๋ํด ํด๋ก์ ์์ ์ ์ฌ์ฉํด์ผ ํ ์๋ ์์ต๋๋ค.
<button onclick={{action (mut factName) "weight"}}>Show weight</button>
๊ธ์, ๊ทธ ๊ฒฝ์ฐ ๋ฌธ์๋ ๊ทธ๊ฒ์ ๋ฐ์ํด์ผํฉ๋๋ค.
์ด์ ์ ๋๋ฌด ๊ฐ์์ค๋ฌ์์ ์ฃ์กํฉ๋๋ค. ์ ๋ ๊ตฌํ์ ๋ํด ์ด์ผ๊ธฐํ๊ณ ์์์ต๋๋ค(์ค์ ๋ก ์ง์ํ๋ ค๋ ๊ฒ์ด ์๋). ๋๋ ํน๋ณํ ์ผ์ด์ค (์์คํ ์ ๋ค๋ฅธ ๊ณณ์์ ์ํ๋๋ mut ๋์ฐ๋ฏธ๊ฐ ์๋ฒฝํ๊ฒ ๊ด์ฐฎ์ ๋ณด์ ๋๋ค.
์ฐ๋ฆฌ๋ ์์ ๊ณต๊ฐ ์ก์ธ์ธ์ ์ด๋ช ์ผ๋ก์ ์ฐ๋ฆฌ๊ฐ ์๋ํ๋ ๋ฐ๋ฅผ ์กฐ๊ธ ๋ ์ ์ฒด์ ์ผ๋ก ๊ฒฐ์ ํ ํ์๊ฐ ์์ต๋๋ค...
@rwjblue ๊ฐ ์ ์ํ ์๋ฃจ์ ์ธ์๋ ์ด๋ฅผ ํด๊ฒฐํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
<button {{action (action mut factName) "weight")}}>Show weight</button>
๋๋ ๊ทธ๊ฒ์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ๋น์ ์ JS Bin์ ํธ์งํ์ต๋๋ค: http://emberjs.jsbin.com/qavaki/1
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@rwjblue ๊ฐ ์ ์ํ ์๋ฃจ์ ์ธ์๋ ์ด๋ฅผ ํด๊ฒฐํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
๋๋ ๊ทธ๊ฒ์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ๋น์ ์ JS Bin์ ํธ์งํ์ต๋๋ค: http://emberjs.jsbin.com/qavaki/1