gpt4 book ai didi

javascript - Ext.AbstractManager.register() : Registering duplicate id "btnLogout" with this manager

转载 作者:行者123 更新时间:2023-11-30 18:06:51 32 4
gpt4 key购买 nike

我做了一个common view,所有页面都需要这个view。所以无论我需要什么,我都将这个 View 称为 xtype 。在这个公共(public) View 中,有一些组件由 id 值定义。

根据要求取决于页面,我需要从公共(public) View 中隐藏一些按钮,再次需要显示。这些事件将取决于页面。首次启动时间屏幕将会出现。一旦我导航到另一个页面,它将显示错误,如 Ext.AbstractManager.register(): Registering duplicate id "btnLogout"with this manager

如果我将组件 ID 值更改为名称值或 itemId 值。然后它将正常导航,但问题是无法隐藏和显示按钮,因为显示未定义的 sysntax 是 var a = Ext.getCmp('btnBackID'); console.log(a);,它将是未定义的。一旦组件作为对象返回,我就可以执行隐藏显示功能。

任何人都可以告诉我如何解决这个问题,或者给我其他实现方法。非常感谢。谢谢。我在下面给出了我的代码

共同观点

Ext.define('abc.view.GlobalNavigationView', {
extend:'Ext.panel.Panel',
alias:'widget.globalNavigationView',
id:'globalNavigationId',
layout: {
type: 'vbox',
align:'stretch'
},
items:
[
{
xtype: 'toolbar',
layout: 'hbox',
flex: 1,
items:
[
{
xtype: 'button',
flex: .1,
text: 'Back',
id: 'btnBackID',
},

{
xtype: 'button',
flex:.1,
id: 'btnSave',
cls: 'saveCls'
},
{
xtype: 'button',
flex:.1,
id: 'btnEmail',
text: 'Email'
},
{
xtype: 'button',
flex:.1,
id: 'btnPrint',
text: 'Print'
},
{
xtype: 'button',
flex:.1,
itemId: 'btnFilter',
text: 'Filter'
},
{
xtype: 'button',
flex:.1,
id: 'btnLogout',
cls: 'logoutCls'
}
]
}

]
});

HomeView1

Ext.define('GulfMark.view.WeeklyHomeView1', {
extend:'Ext.panel.Panel',
alias:'widget.weeklyfcastView',
id:'weeklyfcastId',
layout: 'fit',
items:
[
{
xtype: 'globalNavigationView',
id: 'globalNavigationWeekly1',
flex: 1,
docked:"top",
scrollable:false
},
{
my componets of this view
.........................
}

]
});

HomeView2

Ext.define('GulfMark.view.WeeklyHomeView1', {
extend:'Ext.panel.Panel',
alias:'widget.weeklyfcastView',
id:'weeklyfcastId',
layout: 'fit',
items:
[
{
xtype: 'globalNavigationView',
id: 'globalNavigationWeekly2',
flex: 1,
docked:"top",
scrollable:false
},
{
my componets of this view
-----------------------
}

]
});

Controller 代码:

  init:function(){

this.control({
'globalNavigationView ':{
click:this.onbtnBackClick,
render: this.onbtnBackrender,
},
'weeklyfcastView':{
show:this.onShowweeklyfcastView,
render:this.onRenderweeklyfcastView
}
});
},

onShowweeklyfcastView: function(){

var btnFilter = Ext.getCmp('btnFilter');
console.log(btnFilter); // if i used components id to name or itemId, here will show undefined
btnFilter.setHidden(true);
//btnFilter .hide();

}

最佳答案

如果您的 View 不是单例,则不能为其组件提供 ID - ID 必须是唯一的,否则您会收到duplicate id 错误。

您真正需要的是对试图显示/隐藏按钮的 View 的一些引用。当你有那个引用时,你可以使用 down方法来找到你的按钮。例如:

var iPanel = // Create new panel here.
iPanel.down('button[text="Email"]').hide();

关于javascript - Ext.AbstractManager.register() : Registering duplicate id "btnLogout" with this manager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15613258/

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