Page 1 of 1

Close popup automatically and cancelling barcode scanner

Posted: Thu Oct 31, 2013 2:47 am
by Angela Rogers

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?


Close popup automatically and cancelling barcode scanner

Posted: Thu Oct 31, 2013 3:34 am
by Igor

Hello,

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


Close popup automatically and cancelling barcode scanner

Posted: Thu Oct 31, 2013 9:55 pm
by Angela Rogers

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.


Close popup automatically and cancelling barcode scanner

Posted: Fri Nov 01, 2013 5:15 am
by Illya Stepanov

Hi Angela,

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


Close popup automatically and cancelling barcode scanner

Posted: Fri Nov 01, 2013 3:10 pm
by Angela Rogers

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.


Close popup automatically and cancelling barcode scanner

Posted: Fri Nov 01, 2013 3:28 pm
by Kateryna Grynko

Hi Angela,

Thank you for sharing this!