I have this for loop:
for(tab of tabGroupMain.tabs) {
tab.button.addEventListener("click", function(ev) {
UI.ToggleTab(tab.content, tabGroupMain);
});
}
and if I decide to log the current tab it correctly returns me the current tab e.g.
Object { name: "Info", id: 1, button: span#infoTabButton.title.medium.bold.menuTitle, content: div#infoTabContent.menuTab }
however the moment I try to get the current tab in the addEventListener
method it returns the latest element of the array, no matter which tab it currently is e.g.
Object { name: "Market", id: 0, button: span#marketTabButton.title.medium.bold.menuTitle, content: div#marketTabContent.menuTab }
(should return):
Object { name: "Info", id: 1, button: span#infoTabButton.title.medium.bold.menuTitle, content: div#infoTabContent.menuTab }
code for context:
new UI.Tab("Market", "marketTabButton", "marketTabContent");
new UI.Tab("Info", "infoTabButton", "infoTabContent");
new UI.TabGroup("Main", [UI.tabByName("Info"), UI.tabByName("Market")] );
is the code broken? in that case what can I do to fix it?