Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 9, 2014 02:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/530c4c940c7586706b9a to your computer and use it in GitHub Desktop.
Save devdays/530c4c940c7586706b9a to your computer and use it in GitHub Desktop.
Object JavaScript - Parallel tasks
var data = {}; // JSON data object that feeds the template
data.products = {};
var productTemplate;
Q.all([
getProducts(),
getProductTemplate()
]).then(
function (values) {
data.products = values[0];
productTemplate = values[1];
var renderedPage = Mustache.to_html(productTemplate, data);
$("#products").html(renderedPage);
}, function (err) {
$("#products").text("Load products failed: " + err.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment