The backbone getByCid is not working when i viewed in console.log it showing the error as TypeError: test.getByCid is not a function. By using at(0).cid it shows the output as 'c1' why its not working.
var test=new Backbone.Collection([
{name:'gowtham',age:10}
]);
console.log(test.at(0).cid); // output as c1
console.log(JSON.stringify(test.getByCid('c1'))); //TypeError: test.getByCid is not a function
the
Backbone.Collectiondoes not have methodgetByCid, thats why you are getting this error.But a collection has
getmethod for getting a model.it accepts one argument:
model|id|cidSo if you want to get a model by cid, you can do it like this
collection.get(cidValue)