2

我想将“afterrender”侦听器添加到 view.Viewport 以在渲染视口之后执行某些操作。

有人知道该怎么做吗?

我的代码是,

view.Viewport.js

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

控制器.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....
        });
.
.
.

谢谢!

4

1 回答 1

3

MVC 应用程序架构指南向您展示了如何做到这一点。

从文档:

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');
    }
});

我想如果我将此与您的代码相匹配,它将是:

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');
    }
});
于 2012-06-11T21:46:45.137 回答