PDA

View Full Version : why has the variable passed to tree's store been changed?



wheels765
21 Sep 2011, 6:16 AM
I write code like this:


var label = {text:"text",children:[{text:"text",children:[{text:"text"}]}]}
var g_label = label;
Ext.onReady(function(){
Ext.create("Ext.tree.Panel",{
store:Ext.create("Ext.data.TreeStore",{
root:g_label
}),
height:50,
width:200,
frame:true,
animate:false,
renderTo:Ext.getBody()
});
Ext.create("Ext.tree.Panel",{
store:Ext.create("Ext.data.TreeStore",{
root:g_label
}),
height:50,
width:200,
frame:true,
animate:false,
renderTo:Ext.getBody()
})
})


I use firebug to follow.the g_label variabel has been changed to {text:"text",children:[{text:"text"}]}.
What's more,the label variabel also has been changed to {text:"text",children:[{text:"text"}]}!
Could you tell me how extjs do these?
thanks!

wheels765
21 Sep 2011, 6:20 AM
the variable is changed after Ext.create("Ext.tree.Panel",{}) has been called for the second time