PDA

View Full Version : Access application instance from controller



afortaleza
23 Apr 2011, 8:12 PM
Hello, how can I access the application instance from the controller? I'm writing the application Tommy Maintz wrote for the 2010 Conference on the talk about Structuring your sencha touch application (http://vimeo.com/17705448) and on the Contacts controller I have the following code in the index action:


this.application.viewport.setActiveItem(this.listPanel);

The code assumes that there's a application item associated to the controller (this), but that doesn't seem to be the case, at least not on v1.1.0. I have downloaded the code provided by Tommy (https://twitter.com/#!/tmaintz/status/5370817298829312) but I don't find anywhere where there was such an assignment, there's a application item associated to the Viewport on the creation of the application but that's all.

Google Chrome complains that "application" is undefined.

thank you in advance for any help :)
Anderson Fortaleza

afortaleza
24 Apr 2011, 4:55 AM
Ok, I got it. Reading the docs I've seen that

Instantiating a new application automatically creates a global variable using the configured name property and sets up namespaces for views, stores, models and controllers within the app

I've registered the application with the name "Contacts", so all I had to do was use the global variable for the application like:


Contacts.viewport.setActiveItem(this.listPanel);

And then it worked :)

Anderson Fortaleza