[英]Uncaught TypeError: Object function (){return i.apply(this,arguments)} has no method 'on'
[英]Sencha : Uncaught TypeError: Object function (){h.apply(this,arguments)} has no method 'setActiveItem'
我在我的應用程序中使用以下代碼作為xtype。 我的列表項以我想要的方式出現,但是當我單擊一個項時,每次單擊應該加載帶有數據的新頁面的項時,都會出現此錯誤:Uncaught TypeError:Object function(){h.apply(this ,arguments)}沒有方法'setActiveItem'。 關於如何解決的任何想法? 引用的項目行在代碼中被注釋。
這是我的代碼:
var AppsBack = new Ext.Toolbar({
dock: 'top',
items: [{
text: 'back',
ui: 'back',
handler: function(){
Home.setActiveItem('home'); //Here is the second problem
}
}]
});
var AppsDetails = new Ext.Panel({
id: "appsdetails",
tpl: "{game}",
dockedItems: [AppsBack]
});
var AppsList = new Ext.List({
id: "appslist",
store: AppsStore,
layout: 'card',
emptyText: "No game found",
itemTpl: "{game}",
listeners: {
itemtap: function(view, index, item, e) {
var rec = view.getStore().getAt(index);
AppsDetails.update(rec.data);
AppsBack.setTitle(rec.data.game);
Home.setActiveItem('appsdetails') //Here is the first problem
}
}
});
var AppsListWrapper = new Ext.Panel({
id: "appslistwrapper",
layout: 'card',
items: [AppsList],
dockedItems: []
});
var Home = Ext.extend(Ext.Panel, {
id: "home",
iconCls: 'home',
title: 'Home',
fullscreen: true,
layout: 'card',
cardSwitchAnimation: 'slide',
initComponent: function() {
Ext.apply(this, {
items: [AppsListWrapper, AppsDetails]
});
Home.superclass.initComponent.apply(this,arguments)
}
});
Ext.reg('appsList', Home);
謝謝你的幫助
經過幾次操作,我發現遇到這種麻煩的唯一原因是因為我試圖擴展面板。 換句話說,如果我使用Ext.extend(Ext.Panel)的新Ext.Panel接口,{...一切正常,除非在這種情況下我不能使用xtype。有什么想法嗎?
我想到了!!! 我的解決方案包括為新的擴展類提供盡可能少的參數。 因此,我將home擴展類划分為兩個對象,如下所示:
var Home = new Ext.Panel({
id: "home",
layout: 'card',
cardSwitchAnimation: 'slide',
items: [AppsListWrapper, AppsDetails]
});
var HomeTab = Ext.extend(Ext.Panel, {
iconCls: 'home',
title: 'Home',
layout: 'card',
initComponent: function() {
Ext.apply(this,{
items: [Home]
});
HomeTab.superclass.initComponent.apply(this,arguments);
}
});
Ext.reg('home', HomeTab);
不要問我怎么來,我將無法回答。 我只是按照我的直覺;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.