Sencha : Uncaught TypeError: Object function (){h.apply(this,arguments)} has no method 'setActiveItem'
I am using the following code in my application as an xtype. My list item is开发者_StackOverflow中文版 appearing the way i want but when i click on an item i have this error everytime i click on an item that is supposed to load a new page with datas : Uncaught TypeError: Object function (){h.apply(this,arguments)} has no method 'setActiveItem'. Any idea of how can i fix it? The refered items lines are commented in the code.
Here is my code :
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);
Thanks for your help
After a couple manipulation, i've discovered that the only reason why i am experiencing this trouble is because i am trying to extend the panel. In other terms if i use new Ext.Panel intead of Ext.extend(Ext.Panel, {... everything works fine excepted i can't use xtype in this case. Any ideas?
I figured it out!!! MY solution consists in giving the new extended class as few arguments as possible. Therefore i divided the home extended class into two objects like this :
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);
Don't ask me how come, i won't be able to answer. I just followed my intuition ;)
精彩评论