I have array this.conds = ["addr", "acc"]
for example. I have all these DOM
objects in html tree. All for this piece of code:
for(cond in this.conds) {
this.searchBy[this.conds[cond]] = {
"btn": $("#" + this.conds[cond] + "Btn"),
"fields": $("#" + this.conds[cond] + "Fields"),
"active": false
};
// Handlers
__THIS = this;
this.searchBy[this.conds[cond]].btn.click(function() {
__THIS.setAllUnactive();
__THIS.searchBy[__THIS.conds[cond]].active = true;
__THIS.searchBy[__THIS.conds[cond]].fields.show();
});
}
I cant make handler to handle current element of this.conds
. It handle last element every time. How to avoid this wrong behavior?