Hello,

I want to ask about better practice.

lets look at example function

this.get_active_group = function() {
            var active = '';
            if ($('#dogs_bet_window #first_row').hasClass('listening_keyboard')) {
                active = 'first_row';
            }
            else if ($('#dogs_bet_window #second_row').hasClass('listening_keyboard')) {
                active = 'second_row';
            }
            else if ($('#dogs_bet_window #special_offer').hasClass('listening_keyboard')) {
                active = 'special_offer';
            }
            else if ($('#dogs_bet_window .sum').hasClass('listening_keyboard')) { 
                active = 'sum';
            }
            else if ($('#tabs-3').hasClass('listening_keyboard')) {
                active = 'system_slip';
            }
            return active;
        }

this is the function which which gets currently active group of buttons. My user interface has 5 groups of buttons.

So when I want to determmine which group is active, as you can see in this function - it checks is it having class .listening_keyboard.

The problem might be when design is changed - and if it will not have such ids for example, so the functionality will stop working.

But on the other hand - when changing desing it still will break anyway until we will fix everything. I mean desingners most likely create their own html, will not look at current html. So everything will break anyway.

I was just thinking - keeping the values of active groups in variable. So then I check the variable instead of calling function hasClass() which checks html.

Is it better to store in varible such stuff or not necessary, since then we have doulbe information - in variable and in html, which might look also not optimal

Of course this time there is not that many data but I want to know in general what is better.

IMO having an options variable (array/object) is more readable, plus easier to change. Without it, overlooking a class when changing is easy, especially when the code grows. I think that these kind of identifiers do not belong in code. They can be variables or constants, but they should be defined separately.