I am making a tab based app with Appcelerator. On the master page (info.js) there is a listview showing a list of titles and ids. If one clicks on the item, the id should be passed to the details page (info_details.js). How can I pass the id from the master to the details page in a tabgroup?
I am using code from the sample app, but it does not pass any argument to the sub (details) page: https://github.com/appcelerator-developer-relations/appc-sample-ti520/blob/master/app/controllers/index.js
function onListViewItemclick(e) {
var item = e.section.getItemAt(e.itemIndex);
//var controllerName = e.itemId;
openSample("info_details");
}
function openSample(controllerName) {
var controller = Alloy.createController(controllerName);
$.info.open(controller.getView());
}
Index.xml:
<TabGroup>
<Tab title="Tab 1" icon="KS_nav_ui.png" id="main">
<Window title="Nominate">
<Label>I am Window 1</Label>
</Window>
</Tab>
<Tab title="Tab 2" icon="KS_nav_views.png" id="info">
<Window title="Info">
<Require src="info"/>
</Window>
</Tab>
</TabGroup>
The subpage (info_details) expects
var args = $.args;
var currentNid = args.nid;
You can pass arguments via the createController args parameter. In your case, you can do something like:
function onListViewItemclick(e) {
//e.itemId or whatever you want to send to the controller
openSample("info_details", {nid: e.itemId});
}
function openSample(controllerName, args) {
//pass the args to createController
var controller = Alloy.createController(controllerName, args);
$.info.open(controller.getView());
}
Then in the info_details
:
var args = $.args;
var currentNid = args.nid;