SQLitePlugin (Scope problem)

50 views
Skip to first unread message

Junio Vitorino

unread,
Jun 23, 2012, 3:50:11 PM6/23/12
to phon...@googlegroups.com
Hi everyone,

I'm facing a weird scope problem using the SQLitePlugin that is freaking me out, i can't understand why inside tx.executeSql i can't assign values to a global variable. Look the code below.
 
<script src="https://gist.github.com/2979705.js?file=gistfile1.js"></script>

Someone can explain me, what i'm making wrong?

Vitorino

unread,
Jun 23, 2012, 3:52:05 PM6/23/12
to phon...@googlegroups.com
The code is this one, sorry.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Generated by CoffeeScript 1.3.3
var initData, onBodyLoad, onDeviceReady;

onBodyLoad = function() {
  return document.addEventListener('deviceready', onDeviceReady, false);
};

onDeviceReady = function() {
  this.db = window.sqlitePlugin.openDatabase("RASDatabase", "1.0", "RAS 2011", 20000);
  return initData();
};

initData = function() {
  return this.db.transaction(function(tx) {
    tx.executeSql("SELECT id, name FROM sections;", [], function(tx, res) {
      var _i, _menu;
      _menu = {
        "introducao": "Introdução",
        "desempenho": "Nosso Desempenho",
        "essencia": "Nossa Essência",
        "atitude": "Nossa Atitude"
      };
      _i = 0;
      this.items = "<ul>";
      while (_i < res.rows.length) {
        this.items += "<li>" + _menu[res.rows.item(_i).name] + "</li>";
        _i += 1;
      }
      return this.items += "</ul>";
    });
    return $('body').html(this.items);
  });
};

Vitorino

unread,
Jun 25, 2012, 9:25:37 AM6/25/12
to phon...@googlegroups.com
Hey guys sorry if is a dummy question, but i can't figure out, why i can't assign the values for the variables inside executeSql. Someone could help me?

Sam

unread,
Jun 25, 2012, 1:30:58 PM6/25/12
to phon...@googlegroups.com
Is it working without the plugin (with standard WebSQL) ?
Reply all
Reply to author
Forward
0 new messages