How to update item without save button


#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>

#2

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.


#3

You could use a observer. http://guides.emberjs.com/v1.10.0/object-model/observers/


#4

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
    }
}