[2.1] A bug in Ext.applyIf?
Author:
jane
01 6th, 2009 in
xn--9ou.com
edit
I'm a newbie in component authoring and I was playing around with it. So I created a simple TabTest component that encapsulates a configuration:
Ext.TabTest = Ext.extend(Ext.TabPanel,
{
initComponent: function()
{
Ext.applyIf(this, {
width:450,
activeTab: 0,
frame:true,
defaults:{autoHeight: true},
items:[
{contentEl:'script', title: 'Short Text'},
{contentEl:'markup', title: 'Long Text'}
]
});
Ext.TabTest.superclass.initComponent.call(this, arguments);
}
});
var tabs = new Ext.TabTest({renderTo: "tabs1", width: 800});
The problem here is that "activeTab" is not being applied, I suppose it's because it's value is zero and is probably failing an "if" test that checks if the value is really there.
Regards,
Thiago Souza
http://tdg-i.com/img/screencasts/2008-04-26_2238.swf
applyIf: function(o, c)
{
if(o && c)
{
for(var p in c)
{
if(typeof o[p] == "undefined" o[p] === null)
o[p] = c[p];
}
}
return o;
}
http://tdg-i.com/img/screencasts/2008-04-26_2252.png
applyIf is working.
Eyes open, thats all. ;)
Thanks for the modification. The main reason on using Ext.applyIf instead of Ext.apply in component configuration is to let clients override the encapsulated configuration.
Regards,
Thiago Souza
activeTab : null
Since applyIf only checks for undefined, I'm assuming that activeTab already exists for the object.
#If you have any other info about this subject , Please add it free.# |