Reputation: 556
how do get a controller of a view
var c = Alloy.createController('win', activeTab);
c = c.getView();
Wins.push(c);
in controller win i have function
exports.fun = function() {
};
after getting the win from controller which is the view how do i call this function from a view i need controller to call the function
for ( i = 0; i < Wins.length; i++) {
Wins[i].fun();
}
Wins[i] is a View how do i get a controller of this view so that i can call the function fun()
Upvotes: 1
Views: 2148
Reputation: 33345
dont push the window, push the controller
// this is a bad name for a controller...
var controller = Alloy.createController('win', activeTab);
var view = controller.getView();
// save the controller to a list of global controllers
Alloy.Globals.Controllers = Alloy.Globals.Controllers || {};
Alloy.Globals.Controllers['aController'] = controller;
// loop through all controller and execute func if it exists
for ( var i in Alloy.Globals.Controllers) {
Alloy.Globals.Controllers[i].fun && Alloy.Globals.Controllers[i].fun();
}
Upvotes: 3