I have problem to get sqlite data Cordova-sqlite-storage Plugin and put in menu on Cordova app.
See the part of my code:
var db = window.sqlitePlugin.openDatabase({name: "test.db", location: 'default'});
var items = [];
db.transaction(function(transaction) {
transaction.executeSql('SELECT * FROM categories', [], function (tx, results) {
for (i = 0; i < results.rows.length; i++){
items.push('<li data-page="categories" data-value="'+results.rows.item(i).cat_id+'"><a href="#"><i class="fa fa-'+results.rows.item(i).cat_icon+'"></i><em>'+results.rows.item(i).cat_title+'</em></a></li>');
alert('<li data-page="categories" data-value="'+results.rows.item(i).cat_id+'"><a href="#"><i class="fa fa-'+results.rows.item(i).cat_icon+'"></i><em>'+results.rows.item(i).cat_title+'</em></a></li>');
}
}, null);
});
items.push('<li data-page="categories" data-value="aaa"><a href="#"><i class="fa fa-check"></i><em>Teste</em></a></li>');
jQuery('.menu').append(items);
The problem is that the items.push() in the for() does not work. Why?
The alert() in the for() correctly displays the data.
The second items.push() works correctly.