.submit and executeSql problem
Hi,
i have the following code:
- /******************** campi.js ******************************/
- var campi = {};
- var dbName = 'mobi-lite';
- var db = null;
- var html = '';
- var id_oggetto = 852;
- $(document).ready(function()
- {
- $('#show').click(function()
- {
- //recupero l'utente loggato e in caso di successo recupero le sue attivita'
- campi.showListaCampi();
-
-
- });
-
-
-
-
- });
-
- campi.prova = function(){
- db.transaction(
- function(transaction){
- alert('transaction 2'+transaction);
- transaction.executeSql('select NOME_CAMPO, DETTAGLIO, VALORE, OBBLIGATORIO, VISIBILE'+
- ' from R29_CAMPI_CONSUNTIVAZ'+
- ' where ID_OGGETTO in (852,930)',[],function(){alert('transaction callback');} );
- },function(){alert('error');});
- }
- campi.openDB = function() {
- try
- {
-
- if (!window.openDatabase) {
- alert('not supported');
- }
- else {
- var version = '2.0';
- var displayName = 'database mobi html5 Ibrido';
- var maxSize = 65536; // in bytes
-
- if (db == null) {
- db = openDatabase('mobi-lite', '1.0', 'Database locale Mobi Lite', 200000);
- }
- }
- } catch(e) {
- // Error handling code goes here.
- if (e == 2) {
- // Version number mismatch.
- alert("Invalid database version.");
- } else {
- alert("Unknown error "+e+".");
- }
- return;
- }
- }
- campi.showListaCampi = function(){
- campi.openDB();
-
- html += '<form id="campiConsuntivazione">';
- // Intestazione - inizio
- db.transaction(
-
- function (transaction)
- {
- alert('preselect');
- alert('transaction '+ transaction);
- transaction.executeSql('select NOME_CAMPO, DETTAGLIO, VALORE, OBBLIGATORIO, VISIBILE'+
- ' from R29_CAMPI_CONSUNTIVAZ'+
- ' where ID_OGGETTO in (852,930)',[] ,
- function (transaction, rs)
- {
- //alert('select eseguita');
- //alert('rows: '+ rs.rows.length);
- for (var i = 0; i < rs.rows.length; i ++ )
- {
- //alert('nel ciclo');
-
- var rw = rs.rows.item(i);
-
- var nomeCampo = rw['NOME_CAMPO'];
- //alert('nome campo '+nomeCampo);
- var dettaglio = rw['DETTAGLIO'];
- var valore = rw['VALORE'];
-
- html += '<ul>';
- html+= '<li>';
- html += '<label id = "'+nomeCampo+'">' +nomeCampo+' : <input id = "'+nomeCampo+'" type="text" value="'+dettaglio+'"></input></label>';
- html+= '</li>';
- // Campi Attività - fine
-
- html += '</ul>';
- // Riga Attività - fine
-
- // asyncronous beahviour
-
- }
- html += '<input id="salva" type="submit">Click Me!</input>';
- html += '</form>';
-
-
-
- //var node = document.getElementById('LISTA_CAMPI');
-
- //if (node != null){
- // node.innerHTML = html;
- //}
-
-
- // come innerHTML
-
- campi.prova();
-
- $("#LISTA_CAMPI").html(html);
-
-
- alert('transaction-.'+transaction);
- //gestione bottone salvataggio
- $('#salva').click(function(db)
- {
- alert('aaa');
-
- $('#campiConsuntivazione').submit(function(db) {
- alert('----.sdfs-.'+transaction);
-
-
- campi.prova();
-
-
- });
-
- });
-
- }
-
- //, this.errorHandler
- );
- }
- );
-
- //return html;
- }
First time campi.prova(); is invoked, it execute the transaction and return the success callback.
When it is execute in Jquery .submit the success callback was not invoked..
Why?
Thanks