velugu
1
helloo…
i have try to update on key-press enter but i am not able to do without save option
then how to update item on enter key-press
this my code…
{{#if todo.isVisible}}
{{input value = todo.name }}
<button type ="button" class="btn btn-success" {{action 'updateTodo' todo}}>Save</button>
{{else}}
<span {{action 'editTodo' todo on='doubleClick'}}> {{todo.name}}</span>
<button type ="button" class="btn btn-default" {{action 'delTodo' todo.id}}>X</button>
{{/if}}
</li>
Bind the ‘todo’ value of the input field in the template with the ‘todo’ property, then setup an observer in your component controller like this:
todo: '',
todoDidChange: function(){
//sendAction to your route to update your model here
console.log(this.get('todo'));
}.observes('todo'),
Link to jsbin.
You could use a observer.
You can also bind an action to another event, e.g.:
<input onkeyup={{action "updateName" value="target.value"}} />
actions: {
updateName: function(newName) {
this.get("todo").set("name", newName);
// Do something
}
}