Skip to content

Instantly share code, notes, and snippets.

@acwio
Created July 13, 2015 21:49
Show Gist options
  • Save acwio/3f54aa0b65ee6872330d to your computer and use it in GitHub Desktop.
Save acwio/3f54aa0b65ee6872330d to your computer and use it in GitHub Desktop.
window.apiClient.api.type('projects').get(window.project_id).then(
function(project) {
console.log(project); /* retrieve all the pages for the project */
project[0].get('pages').then(
function(pages) {
/* iterate through each page
* and add content to the model */
for(var key in pages){
/* check for presence of 'url_key' */
if('url_key' in pages[key]) {
console.log(pages[key].url_key);
console.log(pages[key].content);
/* add the relevant content */
if (pages[key].url_key == "education") {
that.set({'education': pages[key].content});
}
else if (pages[key].url_key == "faq") {
that.set({'faq': pages[key].content});
}
else if (pages[key].url_key == "results") {
that.set({'results': pages[key].content});
}
else if (pages[key].url_key == "science_case") {
that.set({'science_case': pages[key].content});
}
}
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment