javascript - Undefined upon get Request in Backbone -
i try execute operation "put" using backbone. fetchs records server. neighter where
nor get
method retrieve solution (result of console.log of code below []
) can edit (using set
) , can save
.
solution can simple still don't realize wrong!
var model = backbone.model.extend({ idattribute : "id" }); var todoscollection = backbone.collection.extend({ model : model, url : myurl }); var todos = new todoscollection(); todos.fetch(); var todo = todos.where({ id : 2 }); console.log(todo); todo.set('name', 'changedname'); todo.save();
you need parse response , specify models are.
for better reference if stumbles on this. like
{ "location": "uk", "users": [ {id: "etc", name: "etc"}, {id: "etc", name: "etc"}, {id: "etc", name: "etc"} ] "someothermeta": "score", "foo": "bar" }
your parse function be:
parse: function(response) { return response.users; }
Comments
Post a Comment