javascript - Phonegap deviceReady not firing -
please excuse me if simple overlooking. making first foray app development using phonegap/cordova platform, appear stuck @ first hurdle. deviceready listener doesn't appear firing.
my code looks so:
alert('0'); document.addeventlistener("deviceready", function(){ alert('1'); db = window.opendatabase("testproject", "1.0", "phonegap test", 200000); alert('2'); if (dbcreated){ alert('3'); db.transaction(getdata, transaction_error); } else { alert('4'); db.transaction(populatedb, transaction_error, populatedb_success); } }, false);
the initial alert('0')
(put in make sure connecting file) firing nothing else happening.
in post on here. else similar problem promted try document.addeventlistener("deviceready", devicereadyfunction, true)
solved issue them, not me.
as side question, how go debugging javascript , inspecting clientside databases in phonegap development? when developing web have firebug , many other tools, phonegap dev relying heavily on deviceready not triggered browser there tools should aware of? (i writing code in coda compiling xcode).
i have code , works fine, have tested using cordova 1.7 , android 2.2
var dbcreated = false; document.addeventlistener("deviceready", function() { alert('1'); db = window.opendatabase("testproject", "1.0", "phonegap test", 200000); alert('2'); if (dbcreated) { alert('3'); db.transaction(getdata, transaction_error); } else { alert('4'); db.transaction(populatedb, transaction_error, populatedb_success); } }, false); function getdata() { } function transaction_error() { } function populatedb(tx) { } function populatedb_success() { }
full source code - https://gist.github.com/3064728
for debugging, use weinre tool debug javascript applications on mobile devices.
http://people.apache.org/~pmuellr/weinre/docs/latest/
phonegap using via - debug.phonegap.com
Comments
Post a Comment