I\'m experiencing problems making database transactions on IOS devices. If the user doesn\'t touch the phone, everything works like expected. If the user taps/scrolls/touche
Our testing showed that this behaviour would also occur whenever the keyboard was displaying and would prevent transactions in an onblur or onfocus event (although, not onkey{down|up|press}). Using setTimeout would cause terrible performance issues. We had found that the .transaction() success callback would be triggered, even if the transaction callback was not called, so came up with this method that works well for us:
var oldOpenDatabase = window.openDatabase;
window.openDatabase = function() {
var db = oldOpenDatabase.apply(window, arguments);
var oldTrans = db.transaction;
db.transaction = function(callback, err, suc) {
var db = this;
var params = arguments;
var hasRun = false;
oldTrans.call(db, function(tx){
hasRun = true; callback(tx);
}, err||function(){}, function(tx) {
if(hasRun){
if (suc != undefined)
suc(tx);
return;
}
else {
oldTrans.apply(db, params);
}
});
}
return db;
}
This code checks that the transaction callback has fired in the success handler and, if not, gives it another chance.