src/hg/lib/hui.c 1.157

1.157 2009/02/10 01:13:04 tdreszer
Obscur change to allow filterBy Dropdowns to load properly in ms ie
Index: src/hg/lib/hui.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hui.c,v
retrieving revision 1.156
retrieving revision 1.157
diff -b -B -U 4 -r1.156 -r1.157
--- src/hg/lib/hui.c	9 Feb 2009 19:40:43 -0000	1.156
+++ src/hg/lib/hui.c	10 Feb 2009 01:13:04 -0000	1.157
@@ -2299,9 +2299,10 @@
     else
         printf("<B>%s</B><BR>\n",filterBy->title);
     int openSize = min(20,slCount(filterBy->slValues)+1);
     int size = (filterBy->slChoices == NULL || slCount(filterBy->slChoices) == 1 ? 1 : openSize);  //slCount(filterBy->slValues)+1);   // slChoice ??
-#define MULTI_SELECT_WITH_JS "<SELECT name='%s.filterBy.%s' multiple=true size=%d onclick='this.size=%d;' onblur='var ix; for(ix=this.selectedIndex+1;ix<this.options.length;ix++) {if(this.options[ix].selected) break;} if(ix == this.options.length) this.size=1; return true;'><BR>\n"
+//#define MULTI_SELECT_WITH_JS "<SELECT name='%s.filterBy.%s' multiple=true size=%d onfucus='this.size=%d;' onblur='var ix; for(ix=this.selectedIndex+1;ix<this.options.length;ix++) {if(this.options[ix].selected) break;} if(ix == this.options.length) this.size=1; return true;'><BR>\n"
+#define MULTI_SELECT_WITH_JS "<SELECT name='%s.filterBy.%s' multiple=true size=%d onclick='this.size=%d;'><BR>\n"
     printf(MULTI_SELECT_WITH_JS,tdb->tableName,filterBy->column,size,openSize);
     printf("<OPTION%s>All</OPTION>\n",(filterBy->slChoices == NULL || slNameInList(filterBy->slChoices,"All")?" SELECTED":"") );
     struct slName *slValue;
     if(filterBy->useIndex)
@@ -2321,8 +2322,11 @@
         for(slValue=filterBy->slValues;slValue!=NULL;slValue=slValue->next)
             printf("<OPTION%s>%s</OPTION>\n",(filterBy->slChoices != NULL && slNameInList(filterBy->slChoices,slValue->name)?" SELECTED":""),slValue->name);
         }
     }
+    // The following is needed to make msie scroll to selected option.
+    //printf("<script type='text/javascript'>$(document).ready(function () { $( 'select[name^=%s.filterBy.]' ).children('option[selected]').each( function(i) { this.selected=true; }); });</script>\n",tdb->tableName);
+    printf("<script type='text/javascript'>onload=function(){ $( 'select[name^=%s.filterBy.]' ).children('option[selected]').each( function(i) { this.selected=true; }); }</script>\n",tdb->tableName);
 puts("</TR></TABLE>");
 
 return;
 }