S
shuchow
Hi, all. I'm using Webkit's Client-side Javascript functionality to
create an app. I have a object method where I'm trying to create a
closure:
getMessages: function() {
var container;
var transactionFunction = function (transaction) {
container = 'one';
var successCallback = function(tx, result) {
container = 'two';
}
var errorCallback = function(tx, result) {}
transaction.executeSql('SELECT * FROM message', [], successCallback,
errorCallback);
}
this.systemDB.transaction(transactionFunction);
return container;
}
For those not familiar with the client-side js api, there is a
database connection (this.systemDB in this case) that takes a function
(transactionFunction) that executes sql. Any calls to transcation.
executeSql is part of the transaction. The executeSql function
requires two call backs - one for success and one for failure.
From what I understand, the container variable should be in scope at
least when it's set to 'one' and when it's set to 'two.' However,
it's not being set. When the function is called, it returns
undefined. Any ideas?
(what I'm ultimately trying to do is to return the result variable
back to the caller of this getMessages function)
Thanks for any insight.
create an app. I have a object method where I'm trying to create a
closure:
getMessages: function() {
var container;
var transactionFunction = function (transaction) {
container = 'one';
var successCallback = function(tx, result) {
container = 'two';
}
var errorCallback = function(tx, result) {}
transaction.executeSql('SELECT * FROM message', [], successCallback,
errorCallback);
}
this.systemDB.transaction(transactionFunction);
return container;
}
For those not familiar with the client-side js api, there is a
database connection (this.systemDB in this case) that takes a function
(transactionFunction) that executes sql. Any calls to transcation.
executeSql is part of the transaction. The executeSql function
requires two call backs - one for success and one for failure.
From what I understand, the container variable should be in scope at
least when it's set to 'one' and when it's set to 'two.' However,
it's not being set. When the function is called, it returns
undefined. Any ideas?
(what I'm ultimately trying to do is to return the result variable
back to the caller of this getMessages function)
Thanks for any insight.