Object JavaScript - Parallel tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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