0

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.

Tiago
  • 358
  • 2
  • 14

1 Answers1

1

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"
});
Rayweb_on
  • 3,727
  • 20
  • 24