Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 9, 2014 02:22
Embed
What would you like to do?
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