javascript - Why does this variable reference not work? -


this.prefixmonday[0] exists @ current scope this.prefixmonday array of 3 checkboxes within initcomponent method of extend of panel

this.weekdays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];  for(var = 0; i<7; i++){    this['prefix' +this.weekdays[i] +'[0]'].on('check',this.somefunction, this); } 

firebug says can't find: this['prefix' +this.weekdays[i] +'[0]']

i'm pretty sure have acces

this['prefix' +this.weekdays[i]][0] 

otherwise javascript search key string 'prefixmonday[0]' , don't think want. make more readable might want use helper variable store name:

for(var = 0; i<7; i++){     var key = 'prefix' +this.weekdays[i];     this[key][0].on('check',this.somefunction, this); } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -