Search code examples
extjsextjs4extjs4.2extjs-mvc

ExtJS 4.2.1 - Cannot get View instance from the controller


In my app I have the viewport with one item, a main view, which it is a simple class extending from Ext.container.Container.

I have a main controller too, and I'm trying to get the view instance, so dynamically I can push the corresponding items if the user is logged or not.

I've tried using views: ['MainView'], refs[ { selector: 'thextype' }], etc with no luck.

I was using the reference (ref) in sencha touch to do this kind of things, can you help me with Extjs v4.2 ?

Just for clarification, I'm not trying to get the DOM element, I'm trying to get the view instance with the associated methods.

Thanks in advance,


Solution

  • After some time debugging, it seems the problem was the context where it was being called the function.

    I've added in the init method a line like:

    var openCrmDashboardFn = Ext.Function.bind(this.onOpenCrmDashboard, this);
    

    and it worked.

    Thank you!