I am using backbone with Node and Express. I have my restful api set up to return my model and collection data. The api works fine. But I'm having trouble binding a route to one of my api paths.
I have a company model and collection so that when go to the routes you get the restful api data for that route:
http://localhost:3000/employees
you get the data for restful api path api/employees
http://localhost:3000/employees/1
you get the data for restful api path api/employees/1
I also have a category model and collection to do the same:
http://localhost:3000/categories
you get the data for restful api path api/categories
but the following does not work:
http://localhost:3000/categories/Auto
you don't get the data for restful api path api/cateogries/Auto
The restful api works and returns the right data, but the collection I get in my app returns the same data as the category collection called with the path api/cateogries
. Almost like the path gets ignored.
Typically you have a collection and then you provide a id attribute to get a model that belongs to that collection. But what if you want a collection whose id attribute returns another collection? For example, you get a list of categories and then when you select a category you get a list of all the companies in that category? What is the right way to do this in backbone?