Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone.js Collection and Tastypie filters

Instead of retrieving the entire table of records for a Backbone collection I've defined, I reckon it's much more efficient to make use of the tasty-pie filters I've created. How would I let Backbone use them? As far as I understand, Backbone models/collections only point to the top-level URI of the model.

e.g. I have a Bookings model defined in Django that can be accessed via "/api/booking" but i want to populate the Backbone Collection with "/api/booking?room=3" where the room number is context specific.

like image 482
sw00 Avatar asked Aug 15 '11 09:08

sw00


1 Answers

I've found out that backbone's .fetch() method accepts the "data" attribute just like JQuery .ajax().

booking.fetch({ data : { "room" : 3 } });
like image 186
sw00 Avatar answered Sep 20 '22 22:09

sw00