PDA

View Full Version : Avoid: Registering duplicate id "XYZ" with this manager



punith.mailme
22 Jun 2012, 11:36 PM
Hi,

I have small issue here,
My senior team menber is creating a widget inside the panel as below

Ext.getCmp('selectedopptionsId').add(Ext.widget('selectedprimary'));

but when i use the same page and create another Ext.widget('selectedprimary') i see in console
Uncaught Ext.Error: Registering duplicate id "primarywantid" with this manager


Please let me know the correct way to see if the widget is already created, and i can use the same.....

evant
22 Jun 2012, 11:40 PM
There's nothing special about it. If you register it once, you can't use it again, id's needs to be unique across the app.

punith.mailme
22 Jun 2012, 11:54 PM
Nope i dint get that..
Please clarify more on this..

My requirement is:
Say i have 2 buttons, on button 1 action i am adding widget "xyz" to my panel1.

Ext.getCmp('panel1').add(Ext.widget('xyz'));

and say button 2 action again adding widget "xyz" to my panel1.

Ext.getCmp('panel1').add(Ext.widget('xyz'));

if i have clicked button1 and click on button 2 i am seeing this
Uncaught Ext.Error: Registering duplicate id "primarywantid" with this manager.

Please clarify,
Thanks,
Punith

evant
23 Jun 2012, 12:03 AM
Exactly that. If you specify an id on the class definition:



Ext.define('Foo', {
id: 'x'
});

var a = new Foo();
var b = new Foo();


You're going to end up with duplicate id's. Don't do that.