Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (mvc)
Viewing all articles
Browse latest Browse all 25

Unable to pass argument to splitWindow in Alloy, just get undefined.

$
0
0

MVC - Passing variables

We are checking out Appcelerator for our company needs so I got tasked with writing an app for the iPad.

Here is some info:

  • Mobile application for the iPad
  • Appcelerator Command-Line Interface, version 4.0.1
  • activeSDK: 4.0.0.GA
  • Appcelerator Studio, build: 4.0.0.201505202026
  • Using Mac OS X 10.10.3
  • Running the app in iOS8.3 on the iPad2 Simulator

The app has the regular index controller and view which in turn run a loginView controller and view. From there at successful login the mainView controller and view is run. The mainView is a Titanium.UI.iOS.SplitWindow.

The problem I am facing is the following, I am trying to pass the user data of the person logging in through the loginView to the mainView. I am used to Codeigniter MVC and there I just pass a variable and it is available in the view, I figured it should be something similar here but can not get it to work.

So this is the relevant loginView.js code:

var mainView = Alloy.createController( 'mainView', { userId : 'some user' } ).getView();
mainView.open();
mainView.js code:
var args = arguments[0] || {};
Titanium.API.debug('Debug pass variables: ' + JSON.stringify(args));
Ti.API.info('args' + args);
Ti.API.info('args' + args.userId);
The code above is not in a function but the root of mainView.js. I have tried passing things like this from loginView.js:
var stuff = { test : 'name' };
var stuff = { 'test' : 'name' };
var stuff = []; stuff.push( { test : 'name' } );
...
var mainView = Alloy.createController( 'mainView', stuff ).getView();
mainView.open();
It all comes out as undefined in the console. After having tried everything I found on Google and in the Appcelerator documentation I seem to have exhausted my options and would greatly appreciate any pointers to what I am doing wrong.

Viewing all articles
Browse latest Browse all 25

Latest Images

Trending Articles





Latest Images