My application has an auto-complete text element and when the selected item is chosen, there is a RESTful ajax call that queries a secondary system which returns a detailed version of the selected object along with an array. It looks something like this:
{
"state": "GA",
"name": "Some Name",
"status": "Appointed",
"address2": "",
"phone": "555-555-5555",
"postalCode": 7777777,
"agents": [
{
"middleName": "Rhett",
"firstName": "Elmer",
"id": 123456,
"email": "",
"documentDeliveryOptions": [],
"lastName": "Butler Jr"
},
{
"middleName": "Alvin",
"firstName": "Frank",
"id": 9123456,
"email": "",
"documentDeliveryOptions": [],
"lastName": "Brown Jr"
}
]
}
Originally, I made the query using a Collection, but I'm not really returning a Collection. I'm returning a single object with a nested Collection. So my question is, what is the appropriate Backbone way to query for this object and then populate a SELECT element with the nested Collection of agents
?
Outside of backbone, I'd make a simple $.getJSON()
call and then parse the response. I'm just not familiar enough with Backbone to understand what the best pattern is for the framework.