← Back to team overview

dhis2-devs team mailing list archive

Re: Minor javascript cross-browser hack

 

On Fri, Jan 22, 2010 at 12:16 PM, Viet Nguyen <phamquocviet@xxxxxxxxx>wrote:

> 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,
>



OK thanks for pointing this out. There might be a centralised method for
this in commons.js or lists.js. Is this already taken care of in jQuery, if
so could we use that instead?

Follow ups

References