0

Array of buttons

I was trying to create an array of button for the menĂ¹ i was implementing, cause i wanted to dinamically disable the button that was last pressed and let the others enabled.
In the create view i used this code
CODE
menuCategory.forEach(function(buttonConfig) {
buttonArray=[];
buttonArray[buttonConfig.ID]=new KONtx.control.TextButton({
...});
}

but when i try this in the updateView
CODE
menuCategory.forEach(function(buttonConfig) {
buttonArray[buttonConfig.ID].setText(buttonConfig.label);
}

I get the error saying :
TypeError: buttonArray[buttonConfig.ID] has no properties (Combofinale.js: Line 92)

while i don't get this problem if i use a single button instead of an array of button, did i do something wrong in using the array or are the array of buttons not possible?

by
1 Reply
  • Try this - not tested, but it should help scoping it to the main view

    CODE
    menuCategory.forEach(function(buttonConfig) {
    this.buttonArray=[];
    this.buttonArray[buttonConfig.ID]=new KONtx.control.TextButton({
    ...});
    }


    CODE
    menuCategory.forEach(function(buttonConfig) {
    this.buttonArray[buttonConfig.ID].setText(buttonConfig.label);
    }
    0

Recent Posts

in Getting Started / Beginners - Yahoo! TV Widgets