I'm trying to get data from a service that returns it wrapped in a function but it doesn't seem to be working and I'm not sure why. I can see the data coming back fine, but then nothing else happens. Is there something else I need to do? Here's my setup:
The json file looks something like this:
This works fine without the callback.
- Cat = can.Model({
findAll: 'GET caturl',
dataType: 'jsonp'
}, {});
- Catlist = can.Control({
init: function() {
this.element.html(can.view('images/js/mn/temps/catlist.ejs', {
catdata: this.options.catdata.cats
}));
}
});
- Cat.findAll({}, function(catResponse) {
new Catlist('.mn_cats', {
catdata: catResponse
});
});
The json file looks something like this:
- callBack(
- {
"cats": [
{
"name": "Sports & Recreation ",
"id": "",
"searchName": "",
"children": [
{
"name": "Exercise & Fitness",
"id": "61",
"searchName": "Exercise-Fitness"
},
{
"name": "Sports & Outdoors",
"id": "21",
"searchName": "Sports-Outdoors"
},
{
"name": "Toys & Games",
"id": "34",
"searchName": "Toys-Hobbies"
}
]
},
{
"name": "Travel ",
"id": "",
"searchName": "",
"children": [
{
"name": "Car Rentals",
"id": "66",
"searchName": "Car-Rentals"
},
{
"name": "Cruises",
"id": "48",
"searchName": "Cruises"
},
{
"name": "Flights",
"id": "64",
"searchName": "Flights"
},
{
"name": "Food & Dining",
"id": "42",
"searchName": "Food-Dining"
},
{
"name": "Hotels & Accommodations",
"id": "53",
"searchName": "Hotels-Accommodations"
},
{
"name": "Travel Accessories",
"id": "24",
"searchName": "Travel Accessories"
},
{
"name": "Vacation Packages",
"id": "58",
"searchName": "Vacation-Packages"
}
]
}
]
}
This works fine without the callback.