Skip to content

Instantly share code, notes, and snippets.

@nachopants
Created May 19, 2016 05:58
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 nachopants/5d4bc4892b22403d386d63ad9e623d20 to your computer and use it in GitHub Desktop.
Save nachopants/5d4bc4892b22403d386d63ad9e623d20 to your computer and use it in GitHub Desktop.
this.generateDocuments = function() {
self.updateOrder();
self.isGenerating(true);
$.each(self.selectedPack().documents(), function(key, doc) {
if (doc.generateDocument() === true) {
self.documentPayload.push(doc);
}
});
$.each(self.documentPayload(), function(key, doc) {
doc.isGenerating(true);
self.generateDocument(doc);
doc.isGenerating(false);
doc.isGenerated(true);
});
}
this.generateDocument = function(doc) {
$.ajax({
beforeSend: function() {
self.isGenerating(true);
},
url: doc.url(),
type: 'GET',
contentType: 'application/json',
data: true,
success: function(response) {
if (response.data) {
doc.isGenerating(false);
doc.isGenerated(true);
}
},
async: true
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment