gpt4 book ai didi

Extjs4 MVC,将监听器添加到视口(viewport) Controller 中的 view.Viewport

转载 作者:行者123 更新时间:2023-12-04 05:43:28 31 4
gpt4 key购买 nike

我想将“afterrender”监听器添加到 view.Viewport 以在渲染视口(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....
});
.
.
.

谢谢!

最佳答案

MVC Application Architecture指南向您展示了如何做到这一点。

从文档:

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

关于Extjs4 MVC,将监听器添加到视口(viewport) Controller 中的 view.Viewport,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10986827/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com