← Back to team overview

dhis2-devs team mailing list archive

Minor javascript cross-browser hack

 

Hi,

Just a minor javascript cross-browser hack.

When adding an options to a select tag using javascript, I can see in DHIS
you are doing like this :

 optionComboSelector.add( option, null );

This will only work on gecko-based browsers. For IE ( tested with IE 8  & 7
) it will throw error ,  the right one should be like this :

 optionComboSelector.add( option ); // only one param

So the solution should be :

   try {
        optionComboSelector.add( option, null );  // for gecko-based
browser...not tested with other webkit-based browsers ...
    }catch(e){
        optionComboSelector.add(option);  // just for IE
    }

A common method in common.js should be useful.

Regards,

-- 
Viet Nguyen

Follow ups