Skip to content

Instantly share code, notes, and snippets.

@gRegorLove
Last active March 29, 2016 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gRegorLove/b6c4d49124dacf47c17f56da998de360 to your computer and use it in GitHub Desktop.
Save gRegorLove/b6c4d49124dacf47c17f56da998de360 to your computer and use it in GitHub Desktop.
document.querySelector('#output') is not updating on subsequent page loads
// This function is defined as part of the window.dao object
loadProduct: function(product_id) {
var output = '';
// async db transaction
this.db.readTransaction(
function(tx) {
var sql = 'SELECT * FROM products WHERE id = ? AND deleted IS NULL';
tx.executeSql(sql, [product_id],
// query success callback
function(tx, results) {
var row = results.rows.item(0);
output += 'Product ID ' + row.id;
console.log('output 1: ' + output);
document.querySelector('#output').innerHTML = output;
console.log(document.querySelector('#output'));
},
// query error callback
self.queryErrorHandler
);
},
// transaction error callback
this.txErrorHandler,
// transaction success callback
function() {
console.log('output 2: ' + output);
}
);
}
// This is outside the window.dao object
app.on({page: 'product', preventClose: true, content: 'product.html'}, function(activity) {
activity.onReady(function() {
console.log('onReady: product');
});
activity.onHashChanged(function(id) {
console.log('onHashChanged: product ' + id);
window.dao.loadProduct(id);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment