Filtering
Tastypie comes with a very good filtering mechanism which allow API users to do the same type of queries what you would write in Django. Why not leverage that and make the server-side do the heavy lifting and the client side only fetches what it actually needs? That’s exactly what filtrate method does in the extended backbone library. With resetFilter the given parameter can be removed from the filters.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
var FilterView = Marionette.CollectionView.extend({ ... events: { 'change select': 'change' }, ... change: function (ev) { var self = this; var params = {}; if (ev.currentTarget.value.length > 0) { params[ev.currentTarget.name] = ev.currentTarget.value; this.collection.filtrate(params); } else { self.model.get('collection').resetFilter([ev.currentTarget.name]); } } }); |
Recent comments