Reputation: 378
is it possible to fetch on backbone, by a different attribute?
Now I can only fetch by ID which will return /url/IDVALUE is is possible to do
model.fetch({name:'VALUE'});
and then it will generate the /url/NAMEVALUE ?
Thanks.
Upvotes: 0
Views: 61
Reputation: 3727
this is a workaround and I think you should use this just to do the fetch but I think it can work
change the IdAttributte and use the name, then when you fetch your model the url will use the name attribute
http://backbonejs.org/#Model-idAttribute
var Model = Backbone.Model.extend({
idAttribute: "name"
});
Upvotes: 1