PDA

View Full Version : How to create dynamic variable names for ExtJS objects?



darkhorni
28 Aug 2014, 11:00 PM
I am trying to create

window1 = Ext.create('Ext.window.Window', {

then

window2 = Ext.create('Ext.window.Window', {

and so on.

I want them to be created in the for loop that I already have but the standart dynamic variable names for JavaScript didn't work, probably because it wants me to write new or may be something to do with global scope, I don't know.

zz9pa
3 Sep 2014, 2:45 AM
You can use an object or an array to store them ?


var arr=[];

for (a=0;a<10;a++) {
arr.push(Ext.create(...
}

Or

var myWindows={};
for (a=0;a<10;a++) {
var nm="window"+a;
myWindows[nm]=Ext.create(...
}



( I *think* you might be able to declare global variables by using the browsers 'window' object )