我想添加'afterrender'监听器来view.Viewport在渲染视口后执行某些操作。
有人知道怎么做吗?
我的代码是,
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....
});
.
.
.
谢谢!
答案 0 :(得分:3)
MVC Application Architecture指南向您展示了如何做到这一点。
来自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');
}
});
我想如果我将其与您的代码相匹配,那么它将是:
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');
}
});