2

I want to add 'afterrender' listener to view.Viewport to do something after render viewport.

anybody know how to do this?

My code is,

view.Viewport.js

Ext.define('App.view.Viewport', {
    extend: 'Ext.container.Viewport',
    alias: 'widget.viewport',
.
.
.

controller.Viewport.js

Ext.define('App.controller.Viewport', {
    extend: 'Ext.app.Controller',
    init: function (application) {
        if (this.inited) {
            return;
        }
        this.inited = true;

        //console.log(this.getViewport());
        this.getViewport().addListener('load', function () {
            console.log('AFTER RENDER'); // it does not work....
        });
.
.
.

Thank you!

1 Answer 1

3

The MVC Application Architecture guide shows you exactly how to do that.

From the doc:

Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',

    init: function() {
        this.control({
            'viewport > panel': {
                render: this.onPanelRendered
            }
        });
    },

    onPanelRendered: function() {
        console.log('The panel was rendered');
    }
});

I guess if I match this to your code, it will be:

Ext.define('App.controller.Viewport', {
    extend: 'Ext.app.Controller',

    init: function() {
        this.control({
            'viewport': {
                afterrender: this.onViewportRendered
            }
        });
    },

    onViewportRendered: function() {
        console.log('The viewport was rendered');
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.