arshabh
arshabh

Reputation: 166

How to add code that runs after application launch in EXTjs MVC architecture

I know that init() executes before the application launch function is called. But I have some code that should be rendered only after the whole application has been launched. Please guide me with this. I need to write it in controller class of my MVC architecture application.

Ext.define('MyApp.controller.Main', {

    extend: 'Ext.app.Controller',

     models: [
        'Leave'
    ],
    stores: [
        'MyJsonStore'
    ],

    views: [
        'Login',
        'MyViewport',
        'ManageColumn'
    ],

    init:function(){

        this.control({
            'managecolumn':{
                  afterrender:this.allowEdit
        }
    });
            },

         allowEdit:function(){
        console.log(Ext.get('edit'));

       }

});

I am getting null for Ext.get('edit') but when I enter same command in console I get a positive response.

Upvotes: 4

Views: 5016

Answers (3)

Johan Haest
Johan Haest

Reputation: 4421

You could also use the launch function in Ext.application.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.app.Application-method-launch

onLaunch works for me in the controllers though...

Upvotes: 2

dbrin
dbrin

Reputation: 15673

Without knowing exactly what 'edit' element is and how it is set - it is difficult to give you a precise answer. However, take a look at this MVC example that uses launch function on the Application class http://jsfiddle.net/dbrin/wULET/

The viewport is created on launch, and you could potentially do what you are looking for.

Upvotes: 0

Brian Moeskau
Brian Moeskau

Reputation: 20431

Have you tried adding an onLaunch method?

Upvotes: 1

Related Questions