I have a big problem. I know it\'s about callback, closure but I don\'t know how to solve the problem. Here is my code
$.Model.extend(\'Article\',
{
fin
Your trying to use the result synchronously, that is your accessing result before its defined (actually in your code example its not undefined, its an empty array) though I expect thats because you had moved the declaration from its original position trying to figure out what was happening.
Try this modified example:-
$.Model.extend('Article',
{
findAll : function(params, success, error){
db.transaction(function(tx) {
tx.executeSql('select * from contents', [], function(tx, rs) {
var result = [];
for(var i=0; i
Article.findAll() is now an asynchronous function, and its callback (closure) receives the results.