There is an error in index.js,line 43 that say:
Uncaught TypeError: Cannot read property 'querySelector' of null
var db = null;
var db2 = null;
var db3 = null;
var dbUser = null;
var dbName = "estudos.db";
var app = {
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
onDeviceReady: function() {
this.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
43 line--> var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
dbUser = window.sqlitePlugin.openDatabase({name: 'user.db', location: 'default'});
dbUser.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Users (flg_aceite, flg_valid_bd)');
}, function(error) {
alert('Transaction ERROR: ' + error.message);
}, function() {
console.log('Database OK');
});
window.plugins.sqlDB.copy(dbName, 0, copysuccess, copyerror);
}
};
app.initialize();
function copysuccess()
{
db = window.sqlitePlugin.openDatabase({name: dbName});
dropTable();
fts_table();
}
function copyerror(e)
{
db = window.sqlitePlugin.openDatabase({name: dbName});
}
function fts_table(){
db.transaction(function(tx) {
tx.executeSql('CREATE VIRTUAL TABLE vtestudos USING FTS3(titulo, texto, id_titulo)', [], function(tx,res){
db.transaction(function(tx) {
tx.executeSql('INSERT INTO vtestudos(titulo, texto, id_titulo) SELECT titulo, texto, id_titulo FROM estudos', [], function(tx,res){
console.log('insert ok');
});
}, function(err){
alert(err.message);
});
});
}, function(err){
alert(err.message);
});
}
function dropTable()
{
window.plugins.sqlDB.remove("estudosprev1", 0, rmsuccess,rmerror);
window.plugins.sqlDB.remove("estudosprev2", 0, rmsuccess,rmerror);
}
function rmsuccess()
{
console.log('existe versão anterior');
}
function rmerror(e)
{
console.log('n existe versão anterior. ignoro.');
}
What I have tried:
I have tried to delete the line especified, but... The same error continue.