So I can fetch a collection from the database and display it using this code:
var articles = new SimpleGoogleReader.Collections.Articles();
articles.fetch({
success: function(articles){
var view = new SimpleGoogleReader.Views.ArticlesIndex({model: articles});
view.render();
}
});
and it works just fine.
In my Rails models (switching to rails for a sec) I have a publication model and an article model. Each Publication has many articles and each article belongs to one publication. Also, each article has a publication_id column.
Back to Backbone. Now what I would like to do is, from Backbone, fetch my articles collection but only the articles that have a specified publication id. Here is what I have:
articles_by_id: function(id){
var articles = new SimpleGoogleReader.Collections.Articles();
articles.fetch({
data: {publication_id: id},
success: function(x){
console.log(x);
}
});
}
This is still getting me all of the articles and not the filtered version I am looking for. For the moment I just want to print the data to the console to see if I am getting the proper data. I will deal with rendering views later.
Any ideas?