I'm creating a simple Todo App as I explore EmberJS v2.14. I want to build in a manual inline editing feature--the user will double-click on a todo line item text span, to open up a input field. The user will then edit the todo, which will be double bound to a backing object. And then when focus is lost, the app will re-close the input field back to the newly edited text.
The following fragment of code is inside an {{each}}
block helper, and it almost works.
{{#unless todo.isOpenForEdit}}
<span {{action 'openForEditing' todo on='doubleClick'}}>{{todo.text}}</span>
{{else}}
{{input type="text" value=todo.text action='closeForEditing' on='focus-out'}}
{{/unless}}
Working Pieces
openForEditing()
is correctly called with the write argument.)closeForEditing()
is correctly called when focus is lost from the input field.Pieces Not Working
closeForEditing()
handler can do the appropriate work of setting
isOpenForEdit
back to false.--
Q) How do I pass an argument to an action handler while working with the input helper?
Q) Is there a different approach I can take, to achieve my goal?
You can pass your action in following way:
{{input type="text" value=todo.text focusOut=(action 'closeForEditing' todo)}}