简体   繁体   English

Sencha:未捕获的TypeError:对象函数(){h.apply(this,arguments)}没有方法'setActiveItem'

[英]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. 我在我的应用程序中使用以下代码作为xtype。 My list item is 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'. 我的列表项以我想要的方式出现,但是当我单击一个项时,每次单击应该加载带有数据的新页面的项时,都会出现此错误:Uncaught TypeError:Object function(){h.apply(this ,arguments)}没有方法'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? 换句话说,如果我使用Ext.extend(Ext.Panel)的新Ext.Panel接口,{...一切正常,除非在这种情况下我不能使用xtype。有什么想法吗?

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 : 因此,我将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);

Don't ask me how come, i won't be able to answer. 不要问我怎么来,我将无法回答。 I just followed my intuition ;) 我只是按照我的直觉;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的TypeError:对象函数(){返回i.apply(this,arguments)}没有方法'on' - Uncaught TypeError: Object function (){return i.apply(this,arguments)} has no method 'on' Backbone Error:Uncaught TypeError:Object function(){parent.apply(this,arguments); 没有'on'方法 - Backbone Error: Uncaught TypeError: Object function (){ parent.apply(this, arguments); } has no method 'on' 未捕获的TypeError:对象(JS函数)没有方法“应用” - Uncaught TypeError: Object (JS Function) has no method 'apply' Knockout.js问题:“ h.apply不是函数。 (在“ h.apply(e,r)”中,“ h.apply”未定义)” - knockout.js issues: “h.apply is not a function. (In 'h.apply(e,r)', 'h.apply' is undefined)” Backbone.js和Require.js-未捕获的TypeError:对象函数(){return parent.apply(this,arguments); }没有方法“开” - Backbone.js and Require.js - Uncaught TypeError: Object function (){ return parent.apply(this, arguments); } has no method 'on' 未捕获的TypeError:对象.NumCon没有方法'apply' - Uncaught TypeError: Object .NumCon has no method 'apply' 未捕获的TypeError:对象函数()没有方法项 - Uncaught TypeError: Object function () has no method items 未捕获的TypeError:对象函数()没有方法“替换” - Uncaught TypeError: Object function () has no method 'replace' 未捕获的TypeError:对象函数没有方法 - Uncaught TypeError: Object function has no method 未捕获的TypeError:对象函数没有方法 - Uncaught TypeError: Object function has no method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM