I am trying to filter some data from my collection. I am using where method for the job but it is returning an empty array. Here is the code.
Model:
return Backbone.Model.extend({
urlRoot: server_url + "tasks",
defaults: {
'id': null,
'title': '',
'description': '',
'deadline': null,
'priority': 1,
'status': 1,
'key': '',
'priority_name': '',
'status_name': ''
}
});
Collection:
return Backbone.Collection.extend({
url: server_url + "tasks",
model: TaskModel
});
And using it like:
var taskList = new TaskList();
taskList.fetch({
data: $.param({key: $.cookie('SID')}),
success: function(collection, response){
if(response.error){
window.location.replace('#logout');
}
}
});
taskList.where({status: 1});
taskList have all the data in it. It is not empty. I have tried many combinations but hard luck every time.
I have also consulted from following posts but same result.
Backbone collection where clause with OR condition
Filter backbone collection by attribute value
toJSON on Backbone.Collection#where?
What I am missing here?