Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'd like to see something like this for Backbone collections, e.g. it would take a query on model attributes and generate a subset of the original collection. Then any views (not just lists) tied to this subset would update automatically.

In fact I think with _.fiter() you could probably do this in a few lines.



Voila.

    collection.each(function(model) { 
      model.set({visible: matchesSearch(model)});
    });
And then, in your view:

    model.bind("change:visible", function() {
      $(this.el).toggle(model.get("visible"));
    });
... assuming that you have a "matchesSearch" function that can tell you if a given model matches the current search term.


I've tweaked the proposal at http://stackoverflow.com/questions/6865174/backbone-js-corre... to do just what you describe.


don't want to hijack the thread, but perhaps something like this http://rudasn.github.com/meelo-store ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: