Print.js: onPrintDialogClose does not work on mozila

Created on 6 Sep 2019  路  8Comments  路  Source: crabbly/Print.js

onPrintDialogClose does not work on mozila.
When user closes tab with print document, don't trigger calback

help wanted

All 8 comments

Which version of Mozilla are you using?

onPrintDialogClose also not work for me.
Mozila 69/Chrome 76.0.3809.132
jQuery:1.12.4
print.js:1.0.61
But after sometime I found if I move the mouse out of the window and click other place and then go back the window and click any place of the window will trigger this event:onPrintDialogClose .

This is a tricky feature. The issue with Firefox is a known issue, there is a comment line in the implementation here:
https://github.com/crabbly/Print.js/blob/master/src/js/functions.js#L80

I'll go over this logic whenever I have a chance. PRs are welcomed :)

I have also a problem with the onPrintDialogClose but it's a different problem.
The callback function is executed before the print dialog opens. In the callback function there's an ajax call with a window.location.replace, so I never see the dialog unless I comment out the callback.
Here's how i call the printjs, I hope there's nothing wrong with it.
I tried Mozilla and Chrome.
printJS({ printable: 'print', type: 'html', css: '/stylesheets/print.css', ignoreElements: ['button', 'namefields'], onPrintDialogClose: redirect() });

I have also a problem with the onPrintDialogClose but it's a different problem.
The callback function is executed before the print dialog opens. In the callback function there's an ajax call with a window.location.replace, so I never see the dialog unless I comment out the callback.
Here's how i call the printjs, I hope there's nothing wrong with it.
I tried Mozilla and Chrome.
printJS({ printable: 'print', type: 'html', css: '/stylesheets/print.css', ignoreElements: ['button', 'namefields'], onPrintDialogClose: redirect() });

Hi!
When you use redirect() you are calling the function instantly.
You should use redirect without "()", thats the way to pass the function

This seems to be working fine with the latest version of Firefox. However, the same issue is currently happening when using Chrome on Windows (on MacOS it works fine). I'm closing this issue in favor of #348. If you are still having problems with Firefox or Chrome, please follow / use that thread instead.
Thank you.

@dbathlon You code will run the function right away, as mentioned by @juansss. You can use a constant to hold the function definition, and pass the constant as the callback. Another option is to pass an anonymous function that calls your redirect. Ex.:

onPrintDialogClose: () => redirect()

Hope this helps.

@dbathlon You code will run the function right away, as mentioned by @juansss. You can use a constant to hold the function definition, and pass the constant as the callback. Another option is to pass an anonymous function that calls your redirect. Ex.:

onPrintDialogClose: () => redirect()

Hope this helps.

Thx for your help. I haven't tested it because I don't need the function anymore.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maisumakun picture maisumakun  路  5Comments

PabloSzx picture PabloSzx  路  5Comments

DouglasOGarrido picture DouglasOGarrido  路  3Comments

zhuyinjing picture zhuyinjing  路  7Comments

Orcinuss picture Orcinuss  路  8Comments