I have the following model and collection:
var UserModel = Backbone.Model.extend({
url: 'api/user',
idAttribute:'username',
defaults: {
username:'',
password:'',
email:'',
tags:''
}
});
var UserCollection= Backbone.Collection.extend({
url: 'api/user',
model: UserModel
});
When I retrieve a user from the collection using:
var myUser = collection.get(username);
the username has to be in the correct case, otherwise I just get null as a result.
Is there a way to tell backbone to ignore the case for certain operations like this on?
Sure, you just need to change the relevant code. It is on lines
240-242ofbackbone.js(for documented 0.9.2 version):Change it something like to:
for collection changing
to something like this might work: