Reputation: 1200
I have a scenario that the customer decide on number of tickets to be printed, am using printjs
and it is working perfect with one time print ,but in a loop to print multi,it only print last one ??? a
any one knows why ??
// loop to create and print ticket
for (var i = 0; i < TicketCount; i++) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "xxxxxxxxxxx",
data: TicketCategory,
dataType: "json",
success: function(data) {
// fill in the div with data
$("label[for =lblTicketAmount]").text(data.price);
$("label[for=lblTicketType]").text(data.ticketCategoryName);
$("label[for =lblDate]").text(moment().format('D MMM, YYYY'));
$("label[for =lblTime]").text(moment().format('HH:mm'));
$("label[for =lblUser]").text(data.userData);
$("label[for =lblSerial]").text(data.id);
$("label[for =lblTicketTaxes]").text(data.taxes);
printJS('dvshowdata', 'html');
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('in error');
//alert("error : " + jqXHR.responseText);
}
}).done(function() {
$("#progress").dialog("close");
});
}
Edit : just a not i do not use the index (i) any where inside the the loop ,i call another function , so it is not an index issue ,
Upvotes: 0
Views: 2491
Reputation: 1200
i got the answer below from the developer
https://github.com/crabbly/Print.js/issues/73
the library currently doesn't support printing multiple files. Not sure if this is even something we should do, as the preview screen has to show to the user for each file. Sounds like a quite annoying user experience. I would code something towards merging the files first into a single file, then printing that one file. This would create one print preview only, providing a better user experience.
Upvotes: 1