1
votes

undefined for the second argument when passing value from one screen into another screen

// First Screen Code.

    args [] = {name:'ABCD',value:'1234'};
    argsToken [] = {token:'ABC123DEF456',value:'VALID'};
    var Window = Alloy.createController('SecondView',args,argsToken).getView();

// Second Screen Code
// First argument
    var args = arguments[0] || {};
    var data = [];  
    data    = args;
    Titanium.API.info('data Value::'+data);

// Second arguments

var argsToken = arguments[1] || {};
var token = [];
token = argsToken;
Titanium.API.info('Token Value::'+token);

Here from data i am getting value which is {name:'ABCD',value:'1234'}

for the second arguments[1] with argsToken its getting undefined.

I am not able getting for second argument {token:'ABC123DEF456',value:'VALID'}

4

4 Answers

0
votes

I'm not fully up to speed with Alloy yet, but the function definition shows the Alloy.createController accepting 2 parameters and your example has 3. http://docs.appcelerator.com/titanium/latest/#!/api/Alloy-method-createController

I believe you would need to do something like this:

// First Screen Code.

    var args = [];
    args.push({name:'ABCD',value:'1234'});
    args.push({token:'ABC123DEF456',value:'VALID'});
    var Window = Alloy.createController('SecondView', args).getView();

// Second Screen Code
// First argument
    var arg1 = args[0] || {};
    var data = [];  
    data    = arg1;
    Titanium.API.info('data Value::'+data.name);

// Second argument

var argsToken = arg[1] || {};
var token = [];
token = argsToken;
Titanium.API.info('Token Value::'+token.token);
0
votes

The problem is that the args is an argument which can be splitted to another arguments when the createController is called. So the solution is a dimensional array. So if you want to get the first json object you should call arguments[0][0].name or arguments[0][0].value and so on....

0
votes

// First Screen Code.

args [] = {name:'ABCD',value:'1234'};
argsToken [] = {token:'ABC123DEF456',value:'VALID'};
sendData = {
    args1 : args,
    argsToken1 : argsToken
};
var Window = Alloy.createController('SecondView',sendData).getView();

// Second Screen Code

// First argument

var args = arguments[0] || {};
var data = [];  
data = args.args1;
Titanium.API.info('data Value::'+data);

// Second arguments

var argsToken = arguments[1] || {};
var token = [];
token = args.argsToken1;
Titanium.API.info('Token Value::'+token);

It will work! :)

-1
votes

You can use Ti.App.fireEvent like this

Ti.App.fireEvent("CALLCROPWINDOW", {

       my_image : galimg

    });

    Ti.App.addEventListener('CALLCROPWINDOW', function(e){

        var crop = new CROPIMAGE();

        view.add(crop);

        Ti.App.fireEvent("webPageReady",{

         my_image : e.my_image

        });

     });