View Full Version : down(String selector) method from Container class is not working anymore
phamtieugiao
13 Dec 2011, 3:50 AM
For example I have a panel "view" that contains a button with ID myButton.
In touch 1 and touch 2 pr1, I can select the button with view.down('#myButton')
The down method works in touch 2 pr1, but it doesn't any more in pr2 or pr3.
Is there any alternatives in new versions?
mitchellsimoens
13 Dec 2011, 7:27 AM
Works for me in PR3:
var cnt = Ext.create('Ext.Container', {
fullscreen : true,
items : [
{
xtype : 'button',
itemId : 'myButton',
text : 'Test'
},
{
xtype : 'toolbar',
docked : 'top',
items : [
{
xtype : 'button',
itemId : 'myButton',
text : 'Hello'
}
]
}
]
});
console.log(cnt.down('#myButton'));
console.log(cnt.down('toolbar #myButton'));
I ran into this exact issue with PR3. Something has changed. I fixed it by not using this.down() in my custom view but using down() on a specific element like Mitchell pointed out above.
mitchellsimoens
13 Dec 2011, 7:54 AM
I ran into this exact issue with PR3. Something has changed. I fixed it by not using this.down() in my custom view but using down() on a specific element like Mitchell pointed out above.
Not element... component
phamtieugiao
13 Dec 2011, 8:00 AM
Works for me in PR3:
var cnt = Ext.create('Ext.Container', {
fullscreen : true,
items : [
{
xtype : 'button',
itemId : 'myButton',
text : 'Test'
},
{
xtype : 'toolbar',
docked : 'top',
items : [
{
xtype : 'button',
itemId : 'myButton',
text : 'Hello'
}
]
}
]
});
console.log(cnt.down('#myButton'));
console.log(cnt.down('toolbar #myButton'));
What I see different here is the itemId keyword, I thought it was previously id instead.
Can you explain more about the change?
Not element... component
Yes, I meant "component" but wrote "element". Thanks.
mitchellsimoens
13 Dec 2011, 8:03 AM
What I see different here is the itemId keyword, I thought it was previously id instead.
Can you explain more about the change?
I never use id unless debugging. itemId should be a unique id to it's parent. As you can see by my example, I use the same itemId but since they have 2 different parents they are still unique.
phamtieugiao
13 Dec 2011, 9:08 AM
Tested, if I put like this:
Ext.apply(this, {
_itemId: this.name + 'Button'
});
. Notice the '_' character. Then the down() method works.
Seems like Ext.apply doesn't change the _itemId if declared like this:
Ext.apply(this, {
itemId: this.name + 'Button'
});
rdougan
13 Dec 2011, 9:36 AM
Where are you adding that code? You should never do that anymore. You should always use the setter (setItemId).
phamtieugiao
13 Dec 2011, 9:39 AM
Where are you adding that code? You should never do that anymore. You should always use the setter (setItemId).
I added it in initialize section:
initialize: function(config) {
this.initConfig(config);
Ext.apply(this, {
_itemId: this.name + 'Button'
});
this.callParent(arguments);
}
rdougan
13 Dec 2011, 9:40 AM
Why are you calling initConfig? initConfig will be called when you callParent() (if you are overriding Component).
initialize: function() {
this.callParent();
this.setItemId(this.getName() + 'Button'); //presuming 'name' is a configuration
}
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.