How to filter Backbone.js Collection and Rerender App View? How to filter Backbone.js Collection and Rerender App View? mongoose mongoose

How to filter Backbone.js Collection and Rerender App View?


Have you tried resetting the collection with the result of the "leads" filter?

Something like

window.AppView = Backbone.View.extend({    el: $("#main"),    events: {        "click #leads .highlight" : "filterLeads"    },    initialize: function() {        Jobs.bind('add', this.addOne, this);        Jobs.bind('reset', this.render, this); //render on reset        Jobs.fetch(); //this triggers reset    },    addOne: function(job) {        var view = new JobView({model: job});        this.$("#activitystream").append(view.render().el);    },    //add a render function    render: function() {        this.$("#activitystream").empty(); //empty out anything thats in there        Jobs.each(this.addOne);    },    filterLeads: function() {        Jobs.reset(Jobs.leads()); //reset Jobs with only the leads    }});

Also your AppView has no 'render' method, yet you reference it here:

Jobs.bind('all', this.render, this);