cordova - jQuery mobile $.mobile.changePage not working properly on iPhone in PhoneGap -
i having annoying problem had me stumped 2 days.
i developed phonegap application using jquery mobile framework. developed on android , worked fine.
now, it's supposed cross-platform when brought on iphone, wouldn't past splash screen. followed few red herrings managed zone in on problem in javascript.
it call $.mobile.changepage on in program execution causing problem. appears kind of race condition because when commented out offending line of code, got past splash screen , if ran statement remotely safari development console, worked okay. add frustration, worked okay in safari browser on ipad not within phonegap app more strange.
i followed advice use settimeout workaround got jquery mobile github issue page here: https://github.com/jquery/jquery-mobile/issues/3190
this made work (thankfully!!). however, doing wrong? feel there should better solution merely adding delay program execution.
here code:
$(document).on('pageinit', '#home', onhomepageinit); function onhomepageinit() { $("#home").on("pageshow", checktokenandsync()); } function checktokenandsync() { // check stored values var storedid = window.localstorage.getitem('id'); var tokenvalue = window.localstorage.getitem('token'); if(storedid == null || tokenvalue == null) { // no token value found, direct user login screen obtain 1 // doesn't work. need use settimeout below // $.mobile.changepage("#logindialog"); window.settimeout(changetologindialog, 1000); } } function changetologindialog() { $.mobile.changepage("#logindialog"); } i'm going add comment github issue page.
in case looking quick-fix workaround problem. try using window.settimeout add delay program execution. see question above code.
Comments
Post a Comment