我没有在视图中编写所有组件,而是在我的视图中给出了一个HTML文件的链接,如下所示。我在panelActivate()上调用了sample.html。
所以在这种情况下,我在sample.html中有一个按钮,我想为该按钮编写click事件,以便从一个视图转到另一个视图。那我该怎么做?我认为this方法不起作用
Ext.define('myapp.view.Main', {
extend: 'Ext.Panel',
xtype: 'main',
requires: [
'Ext.TitleBar',
'Ext.Video',
'Ext.Ajax'
],
config: {
tabBarPosition: 'bottom',
id : 'MyPanel',
itemId : 'MyPanel',
scrollable : true,
listeners: [
{
fn: 'onMyPanelActivate',
event: 'activate'
}
],
items: [
{
title: '<div class="small_logo"></div>',
styleHtmlContent: true,
scrollable: true,
html: [
].join("")
}
]
},
onMyPanelActivate: function(newActiveItem, container, oldActiveItem, eOpts) {
Ext.Ajax.request({
scriptTag:true,
url: ' resources/html/sample.html',
success : function(response) {
Ext.getCmp('MyPanel').setHtml(response.responseText);
},
failure : function(response) {
var text = response.responseText;
Ext.Msg.alert('Error', text, Ext.emptyFn); }
});
} });
答案 0 :(得分:1)
它错误地使用了框架,但可以使用jquery并编写click事件来完成 on onMyPanelActivate成功。