Quantcast
Viewing all articles
Browse latest Browse all 8068

Alloy SQLITE preload: Need help passing variable and using it to open new table

With classic:

tableview.addEventListener('click', function(_e) {
        var DetailWindow = require('ui/common/products');
        self.containingTab.open(new DetailWindow(_e.rowData.name, self.containingTab));
    });
In new window with a new sql table:
var prodName = self.name;
 
        var db = Ti.Database.install('products.sqlite', 'products');
        db.file.setRemoteBackup(false);
 
        var rows = db.execute('SELECT * FROM productsDetails WHERE name="' + prodName + '"');
How would you do the same thing in Alloy?

I have check out both of these links below, they got me going with the initial table, but I am having trouble pass the variable to the new window, and opening a new sql table.

https://github.com/appcelerator/alloy/tree/master/test/apps/models/sql_preload

https://github.com/prakash-anubavam/alloypreloadedsqlitedb

var fighters = Alloy.Collections.fighters;
var counter = 1;
 
function showId(e) {
    if (e.row.model) {
        alert(e.row.model);
    }
}
 
function transformData(model) {
    var attrs = model.toJSON();
    Ti.API.info('attrs: ' + JSON.stringify(attrs));
    return attrs;
}
 
function addTestFighter(e) {
    // create the test fighter model
    var model = Alloy.createModel('fighters', {
        name: 'Name ' + counter,
        nickname: 'Nickname ' + counter
    });
    counter++;
 
    // add model to the collection and save it to sqlite, make
    // it silent so binding doesn't fire twice
    fighters.add(model, { silent: true });
 
    // this will save the model to storage, update it with
    // the automatically created id from the "server" (sqlite),
    // which will in turn trigger the UI update
    model.save();
}
 
fighters.fetch();
 
$.index.open();

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>