Reputation: 6403
I'm treying to create a simple todo webapp with jQtouch but I'm having some time creating a SQLite database. Or the database is created with no tables, and when I refresh Safari the database is created again, resulting in many datbases with diffrent names.
$(function() {
var db;
//DATABASE
var shortName = 'todosDB';
var version = '1.0';
var displayName = 'todosDB';
var maxSize = 65536;
db = openDatabase(shortName, version, displayName, maxSize);
db.transaction(
function(transaction) {
transaction.executeSql(
'IF NOT EXISTS CREATE TABLE todos ' +
'(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, ' +
'todo TEXT NOT NULL, description TEXT NOT NULL' +
'date DATE);'
);
}
);
And when I finally create it nothing happens when I try to put some data in the db.
db.transaction(
function(transaction) {
transaction.executeSql(
'INSERT INTO todos (todo, description) VALUES (' + $('#todo').val() + ', ' + $('#description').val() + ' );'
);
}
);
Any help would be appreciated. I don't know if the problem is because of how jQtouch handles the initial function? It seems like the transaction does not even execute which leads me to believe there is something with the opening lines that is the problem.
EDIT: The biggest trouble I have is duplicating databases, every time I refresh the browser it creates another database. The table are created now but since it creates a new database every time it makes a new table every time and so on.
Upvotes: 0
Views: 312