I'm trying to learn ember.js by following Getting Started with Ember.js Using Ember CLI. The tutorial shows you how to build a todo list but I'm having trouble getting the delete action to work. Since I'm new to ember, I'm not 100% sure what code you guys will need to see but the delete button is in app/templates/components/todo-item.hbs:
{{#if editing}}
{{input class="edit" value=todo.title action="submitTodo"}}
{{else}}
{{input type="checkbox" checked=todo.complete class="toggle"}}
<label class="{{if todo.complete 'completed'}}" {{action "editTodo" on="doubleClick"}}>{{todo.title}}</label>
<button class="destroy" {{action "deleteTodo"}}></button>
{{/if}}
I have a delete action in app/components/todo-item.js like so:
actions: {
editTodo() {**code**},
submitTodo() {**code**},
deleteTodo() {
let todo = this.get('todo');
this.sendAction('deleteTodo', todo);
}
}
And in app/routes/todos.js I have:
actions: {
createTodo(newTitle) {**code**},
updateTodo(todo) {
todo.save();
},
deleteTodo(todo) {
todo.destroyRecord();
}
}
When I click on the delete button nothing happens and the following shows up in Ember Inspector console:
Successful request: DELETE /todos/2
Object(with a lot of stuff nested under it)
Error: Assertion Failed: normalizeResponse must return a valid JSON API document: * One or more of the following keys must be present: "data", "errors", "meta".
I'm not really sure what that error means so if anyone could explain and offer a possible solution I'd really appreciate it.
Aucun commentaire:
Enregistrer un commentaire