Angela Rogers
Posts: 0
Joined: Thu Oct 31, 2013 2:47 am

Close popup automatically and cancelling barcode scanner

I am using this javascript: setTimeout("Appery.navigateTo('ScanScreen',{})" , 2000); within an error popup to automatically go back to a page (ScanScreen) that runs the barcode scanning service on Load. However, if I click cancel on the scanning, it keeps popping up this error popup, closes, I hit cancel, and it pops up again, so I can never get out of the scanning. Is there a better way to close a popup automatically after 2 seconds? Is there a way to control what the cancel button on the barcode scanner does?

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Close popup automatically and cancelling barcode scanner

Hello,

Please clarify what event do you use to invoke your JavaScript?

Angela Rogers
Posts: 0
Joined: Thu Oct 31, 2013 2:47 am

Close popup automatically and cancelling barcode scanner

The page "ScanScreen" has a Load event that invokes the barcodescanner service. On success, the barcodescanner invokes a rest service that updates a database. On fail, it loads the error popup. So, I guess clicking cancel on the barcode scanning windows sends a fail instead of just closing. I guess I'll have to change how I have this working.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Close popup automatically and cancelling barcode scanner

Hi Angela,

Can you post code you using to make transition to specific page?

Angela Rogers
Posts: 0
Joined: Thu Oct 31, 2013 2:47 am

Close popup automatically and cancelling barcode scanner

I resolved the issue by mapping the 'cancelled' response from the barcodeservice to a local storage variable, then used the following javascript:

if (localStorage.getItem('scancancelled')=="true"){
Appery.navigateTo('startScreen');
}
else {
myrestservice.execute({});
}

Apparently when you click "Cancel" on the barcode scanning it still fires the Success event. This code did the trick for me. Maybe it will help someone else.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Close popup automatically and cancelling barcode scanner

Hi Angela,

Thank you for sharing this!

Return to “Issues”