0

I'm building an application with Titanium SDK 3 using the AlloySliderMenu widget.

This widget reates a slider menu like Facebook application. It sounds like it is easy to use, but i'm facing the following issue.

In the index.xml I require the widget.

In the index.js of the application, I have the following piece of code:

currentView = Alloy.createController('list').getView();
//ds is the slider menu id
//contentview in the main panel of the menu
$.ds.contentview.add(currentView);

This opens my 'list' view in the main window of the application.

The issue is, in my list.js controller, I have a function which is supposed to change the $.ds.contentview content ith another view on a click action of a button. But I'm unable to access the $.ds.contentview from the list container and use this object.

I've tried Alloy.createWidget etc.. but no way, it won't work.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65

2 Answers2

0

If your problem is the scope, a quick fix can be used globals or CFG variables:

Alloy.Globals.someGlobalObject = { key: 'value' };
Alloy.Globals.someGlobalFunction = function(){};

var theObject = require('alloy').Globals.someGlobalObject;

there id more information about using this variables here: http://docs.appcelerator.com/titanium/latest/#!/api/Alloy

And if that does not resolve the problem, you can send parameters in a JSON object when you create a controller like:

Alloy.createController('list', {
        title : "Unable to login",
        message : authData.FailureReason,
        callback : callbackFunc
    }).getView()

maybe the callback functions can help you out.

Mario Galván
  • 3,964
  • 6
  • 29
  • 39
0

As Mario mentions: In index.js, use a global: Alloy.Globals.ds = $.ds;

In list.js, you can reach the widget by: Alloy.Globals.ds

oskarsprima
  • 109
  • 1
  • 2