Results 1 to 2 of 2
  1.    #1  
    what's wrong with my code? I'm new to webos development, I've been a Microsoft .NET developer for years..

    I've got a simple scene..

    with a header..

    then a collapsible group box ...

    then a list object inside the group box ..

    this is all of my code, it gets to the results data handler and loops through the results .. it just can't insert the item because it can't find lstGames, which is the name of the list.

    function SetupAssistant(argFromPusher) {

    }

    SetupAssistant.prototype = {
    setup: function() {
    Ares.setupSceneAssistant(this);
    this.currentList = this.controller.get('lstGames');

    },
    cleanup: function() {
    Ares.cleanupSceneAssistant(this);
    },
    collapsible1Tap: function(event, inSender) {
    this.db = openDatabase('PTS', '', 'PTS', 65536);

    var string = 'CREATE TABLE Games (Game TEXT NOT NULL); GO;';

    var mytext = 'SELECT * FROM Games';
    this.db.transaction(
    (function (transaction) {
    transaction.executeSql('DROP TABLE IF EXISTS Games; GO;', []);
    transaction.executeSql(string, [], this.createTableDataHandler.bind(this), this.errorHandler.bind(this));
    transaction.executeSql("INSERT INTO Games (Game) VALUES ('Texas Holdem'); GO; COMMIT;",[], this.createRecordDataHandler.bind(this), this.errorHandler.bind(this));
    transaction.executeSql("INSERT INTO Games (Game) VALUES ('Omaha'); GO; COMMIT;", [], this.createRecordDataHandler.bind(this), this.errorHandler.bind(this));
    transaction.executeSql("INSERT INTO Games (Game) VALUES ('Omaha HI/LO'); GO; COMMIT;", [], this.createRecordDataHandler.bind(this), this.errorHandler.bind(this));
    transaction.executeSql(mytext, [], this.lstGamesDataHandler.bind(this), this.errorHandler.bind(this));
    }).bind(this)
    );
    },

    lstGamesDataHandler: function(transaction, results) {

    console.log('I am in the handler...');
    var string = "";

    try {
    var list = [];
    for (var i = 0; i < results.rows.length; i++) {
    var row = results.rows.item(i);
    for (name in row)
    {
    if (typeof row[name] !== 'function')
    {
    var newItem = {itemGames:$L(row[name])};
    console.log(newItem);
    this.controller.get('lstGames').items.push(newItem);
    }
    }
    ;
    //console.log(row[0]);

    }
    //update the list widget
    //console.log(string);
    //this.controller.get("lstGames").clear();
    //Object.extend(this.controller.get("lstGames"),list);
    //this.controller.modelChanged(this.lstGamesModel, this);
    }
    catch (e)
    {
    console.log(e);
    }

    },

    createTableDataHandler: function(transaction, results)
    {
    console.log('Games table created');
    },

    createRecordDataHandler: function(transaction, results)
    {
    console.log('Inserted 1 record.');
    } ,

    errorHandler: function(transaction, error)
    {
    console.log('Error was '+error.message+' (Code '+error.code+')');
    return true;
    }

    };
  2. #2  
    what are you trying to accomplish in your code?

    Looks like you are missing the List Widget init calls in your setup method.

    Adding a row to a list: There's a simple in the SDK on how to do this, I recommend you take a look at it.
    Wifi Media Sync 3.0 now available for PC and Mac OSX.

Posting Permissions