@@ -36,12 +36,6 @@ $(function() {
3636 framework . indeterminate = checkedCount !== 0 ;
3737 }
3838
39- // Submit the form when a user changes the selected 'sortBy' option
40- searchForm . sortby . addEventListener ( 'change' , ( e ) => {
41- searchForm . sortby . value = e . target . value ;
42- submitSearchForm ( ) ;
43- } ) ;
44-
4539 // Accordion/collapsible logic
4640 const collapsibles = document . querySelectorAll ( '.collapsible' ) ;
4741
@@ -68,8 +62,7 @@ $(function() {
6862 }
6963 }
7064
71- searchForm . addEventListener ( 'submit' , submitSearchForm ) ;
72-
65+ // Update query params before submitting the form
7366 function submitSearchForm ( ) {
7467 constructFilterParameter ( searchForm . frameworks , allFrameworks ) ;
7568 constructFilterParameter ( searchForm . tfms , allTfms ) ;
@@ -93,7 +86,6 @@ $(function() {
9386 // Initialize state for Framework and Tfm checkboxes
9487 // NOTE: We first click on all selected Framework checkboxes and then on the selected Tfm checkboxes, which
9588 // allows us to correctly handle cases where a Framework AND one of its child Tfms is present in the query
96- initializeFrameworkAndTfmCheckboxes ( ) ;
9789 function initializeFrameworkAndTfmCheckboxes ( ) {
9890 var inputFrameworkFilters = searchForm . frameworks . value . split ( ',' ) . map ( f => f . trim ( ) ) . filter ( f => f ) ;
9991 var inputTfmFilters = searchForm . tfms . value . split ( ',' ) . map ( f => f . trim ( ) ) . filter ( f => f ) ;
@@ -110,4 +102,14 @@ $(function() {
110102 }
111103 } ) ;
112104 }
105+
106+ // The /profiles pages use this js file too, but some code needs to be applied only to the search page
107+ if ( searchForm ) {
108+ searchForm . sortby . addEventListener ( 'change' , ( e ) => {
109+ searchForm . sortby . value = e . target . value ;
110+ submitSearchForm ( ) ;
111+ } ) ;
112+ searchForm . addEventListener ( 'submit' , submitSearchForm ) ;
113+ initializeFrameworkAndTfmCheckboxes ( ) ;
114+ }
113115} ) ;
0 commit comments