Crysis
Crysis

Reputation: 418

Page doesn't Reload After printing

Page doesn't reloads after printing, using PHP laravel framework, tried all the available javascript and jquery page refresh and reload options, nothing is working, the below window.location.href works but printing doesnt happening, very much confused any help could be useful thanks. Using Jquery print plugin and also tried window.print also.

<button type="button" data-dismiss="modal" id="mymodalss">Print</button>    
    $(document).ready(function() {
    $("#mymodalss").click(function(){

var deferredObj = $.Deferred();

 $.print("#offer",
        {
            deferred: deferredObj
        }
    );    
/*this way working with alert, if i remove alert it doesnt work*/
 deferredObj.done(function(value) {
         alert("Successful in Printing");
         window.location.href ="{{URL('/payroll/voucher')}}";      
    });
  });

});

Upvotes: 1

Views: 636

Answers (2)

vijayP
vijayP

Reputation: 11512

Can you try passing the $.Deferred() option while going for print like below:

$(document).ready(function() {
  $("#mymodalss").click(function(){

    //declaring the deferred object in which page will get reloaded/refresh on .done event
    var deferredObj = $.Deferred();
    deferredObj.done(function(value) {
        window.location.reload(true);
    });

    $.print("#offer",
        {
            deferred: deferredObj
        }
    );    

  });

});

Upvotes: 1

pkovzz
pkovzz

Reputation: 364

I guess you can do simply window.location.href="payroll/voucher".

Upvotes: 1

Related Questions