Last active
March 29, 2016 23:22
-
-
Save gRegorLove/b6c4d49124dacf47c17f56da998de360 to your computer and use it in GitHub Desktop.
document.querySelector('#output') is not updating on subsequent page loads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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