1

Possible Duplicate:
Call controller's function from another controller / Share data between controllers

I am working on sencha touch 2.0 MVC app,i have two controllers in my app.I want to send data from one controller to another.I used push() method to send data but i guess,it's not correct way to do it.So please help me to solve it.Any help would be highly appreciated.

Thanx in advance.

Community
  • 1
  • 1
himanshu
  • 1,990
  • 3
  • 18
  • 36

1 Answers1

1

Generally, push is quite ok, but more simply you can just do this:

Assuming that you are in a function of Controller 1, and want to pass some parameters to Controller 2, then it's possible to call a method in Controller 2 in-place:

Ext.getApplication().getController('controller_2').method(your_params)

But the best practice, if you want to keep your data persistent, is to define Model and Store for your corresponding data. It ensures that your data is available throughout all components of your application and can be changed anywhere you want. It's something like global variables, but just much better than pure Javascript's global variables definition.

Thiem Nguyen
  • 6,345
  • 7
  • 30
  • 50