Kumar Bibek
Kumar Bibek

Reputation: 9117

Accessing view config data from controller in Sencha Touch

I have a View which I instantiate like this. 'content' is some random data that I want to pass which I would use in the View and render the UI with this data.

   var nextView = Ext.create('MyApp.view.NextView',{
        content: content
   });

Now, on the view, I am able to initialize and access this data from within the initialize function of the View.

   iniitalize: function(){
       this.callParent();

       var content = this.config.content;
   }

Now, I have a method in my controller, where I want to get the value of this content. What is the best way to do that? I have been digging through the docs, and searching examples, but, haven't got anywhere.

Upvotes: 2

Views: 2786

Answers (1)

sha
sha

Reputation: 17860

In controller you would need to have refs section http://docs.sencha.com/touch/2.2.1/#!/api/Ext.app.Controller-cfg-refs

refs: {
   myView: 'nextView' // or whatever xtype of your view class is
}

And you will access your view (and all its methods and properties) by using auto-generated getter functions

this.getMyView();

Upvotes: 4

Related Questions