I am trying to figure out how to pass an argument between representations in an alloy. I will have a nav group that has several tables, so it can be from 3 to 5 levels.
I can pass arguments from the controller to the view, but I want to pass the information (category identifiers) from the view to the next table when clicked.
I'm not sure how to do this in the alloy, I always get undefined errors when trying to access a variable. Below is my current setup.
In my views, I have: index.xml, master.xml, row.xml, detail.xml, subDetail.xml
Index.xml
<Alloy> <Window id="index"> <NavigationGroup id="navgroup"> <Require src="master" id="master"/> </NavigationGroup> </Window> </Alloy>
Here is my index.js
Alloy.Globals.navgroup = $.navgroup; $.master.on('detail', function(e) { // get the detail controller and window references var controller = Alloy.createController('detail'); var win = controller.getView(); // open the detail windows $.navgroup.open(win); /* if (OS_IOS && Alloy.isHandheld) { Alloy.Globals.navgroup.open(win); } else if (OS_ANDROID) { win.open(); }*/ }); $.index.open();
master.xml
<Alloy> <Window title="Categories"> <TableView id="table" onClick="openDetail"> </TableView> </Window> </Alloy>
master.js
function openDetail(e) { $.trigger('detail', e); } var data = []; var sendit = Ti.Network.createHTTPClient({ onerror: function(e){ Ti.API.debug(e.error); alert('There was an error during the connection'); }, timeout:1000, });
row.xml
<Alloy> <TableViewRow> <Label id="name"/> <Label id="catID"/> </TableViewRow> </Alloy>
row.js
var args = arguments[0] || {}; $.row.fighterName = $.name.text = args.name; $.catID.text = args.catID;
detail.xml
<Alloy> <Window title="Sub Categories"> <TableView id="subtable" onClick="openSubDetail"> </TableView> </Window> </Alloy>
detail.js
function openSubDetail(e) { $.trigger('subDetail', e); } var data = []; var sendit = Ti.Network.createHTTPClient({ onerror: function(e){ Ti.API.debug(e.error); alert('There was an error during the connection'); }, timeout:1000, });