Ok, really dumb question coming up. It looks like can isn't enjoying my returned JSON doc (below). Is there an easy way to ensure that I'm passing the array of "item" objects from this response to the function here:
- App.findAll({}, function(apps) {
- //Get the Template from above
- var Source = document.getElementById("Handlebars-Template").textContent;
- //Compile the actual Template file
- var Template = Handlebars.compile(Source);
- //Generate some HTML code from the compiled Template
- var HTML = Template({ apps : apps.channel.item.sort(function CustomSort(a, b) {
- return (a.title.localeCompare(b.title));
- }) });
- //Replace the body section with the new code.
- $('#content').html(HTML);
- makeDivSimilar();
- },function(xhr) {
- //Replace the body section with the new code.
- $('#content').html("<h1>API Call Failed</h1>".concat("<p>Fault: ").concat(xhr.responseText).concat("</p>"));
- });
Here's the JSON doc:
{
"channel" : {
"title" : "My Apps",
"link" : "../../atmosphere#/user/user10002.atmosphere/applications",
"description" : "List of applications by user",
"item" : [ {
"title" : "Demo API Tester",
"description" : "A demo test app",
"category" : [ {
"value" : "app",
"domain" : "uddi:soa.com:resourcetype"
}, {
"value" : "Public",
"domain" : "uddi:soa.com:visibility"
} ],
"guid" : {
"value" : "app10221.atmosphere"
},
"pubDate" : "Mon, 30 Dec 2013 18:39:20 -0800",
"Rating" : 0.0,
"Followers" : 1,
"Image" : {
"Url" : "http://atmosphere.soa.local:9900/api/apps/app10221.atmosphere/avatar"
},
"EntityReference" : {
"Title" : "Demo API Tester (1.0)",
"Guid" : "5HhK0fqF4vk8QoJJ4dS7ZN4p.atmosphere",
"Category" : [ {
"value" : "app-version",
"domain" : "uddi:soa.com:resourcetype"
} ]
},
"Connections" : 0
}, {
"title" : "API Tester",
"description" : "App for testing APIs",
"category" : [ {
"value" : "app",
"domain" : "uddi:soa.com:resourcetype"
}, {
"value" : "Public",
"domain" : "uddi:soa.com:visibility"
} ],
"guid" : {
"value" : "app10198.atmosphere"
},
"pubDate" : "Thu, 12 Sep 2013 08:36:51 -0700",
"Rating" : 0.0,
"Followers" : 1,
"Image" : {
"Url" : "http://atmosphere.soa.local:9900/api/apps/app10198.atmosphere/avatar"
},
"EntityReference" : {
"Title" : "API Tester (1.0)",
"Guid" : "7ZO4btcsJPa4mDuO6d7WThzv.atmosphere",
"Category" : [ {
"value" : "app-version",
"domain" : "uddi:soa.com:resourcetype"
} ]
},
"Connections" : 1
} ]
},
"version" : "1.0"
}