'Titanium : How to use a varibale getting form one .js file is to be user in to another .js file
I have implemented an app in titanium. I'm very new to titanium and JavaScript..
My requirement is as follows
I have table view with list of project names
I need to add/append another project by tapping on Add button, which goes to another list of All projects.
I need to select A project from list of AllProjects in 2nd window (AllProjects.JS) and pop to back to 1st window (CurrentProjects.JS) with selected Project and append that selected project in hte currentList of projects.
I tried as follows
IN All Projects.js
$.table.addEventListener('click', function(e) {
var selected = e.row;
alert(e.row.title);
var TodayStatus = new Alloy.createController("TodayStatus");
TodayStatus.SELECTEDPROJECT = e.row.title;
TodayStatus.getView().open();
});
I was unable to retrieve SELECTEDPROJECT to the currentProjects.js file
How to achieve it? Please help me.
How do I declare SELECTEDPROJECT, where do I declare SELECTEDPROJECT, how use it, how to assign a value to it?
Solution 1:[1]
You can pass the data by passing parameter like this.
x.addEVentListener('click', function(e){
var controller = require('controllerPath').createWindow(e.value);
controller.open();
})
And in controller.js
exports.createWindow = function(value)
{
//whatever You like to do with UI
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Krishna Kumar |
