Answer the question
In order to leave comments, you need to log in
How to remove Uncaught TypeError: Cannot read property 'idAttribute' of undefined in Backbone Collection?
Coffeescript code:
UserNameModel =
# idAttribute: 'id'
defaults:
"Name": ""
ProjectGroup = Backbone.Collection.extend
model: UserNameModel
checkUser: (username) ->
findResult = @find (user) -> user.get "Name" == username
findResult != null
SE1 = new ProjectGroup [
{id: 1, Name: "Artem"}
{id: 2, Name: "Airat"}
{id: 3, Name: "Vlad"}
{id: 4, Name: "Maxim"}
{id: 5, Name: "Igor"}
]
Answer the question
In order to leave comments, you need to log in
First, idAttribute must be specified on the model, not on the collection.
Secondly, if you have it equal to 'id', then you do not need to specify it at all - this is the default value.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question