@@ -34,7 +34,9 @@ function initTomSelect(parent) {
3434
3535 var plugins = [ ]
3636 var $el = $ ( this )
37- if ( $el . attr ( 'multiple' ) ) plugins . push ( 'remove_button' )
37+ var isMultiple = ! ! $el . attr ( 'multiple' )
38+ if ( ! isMultiple ) plugins . push ( 'dropdown_input' )
39+ if ( isMultiple ) plugins . push ( 'remove_button' )
3840 if ( hasBlankOption ( this ) ) plugins . push ( 'clear_button' )
3941 if ( hasBlankOption ( this ) && ! $el . data ( 'allow-empty-option' ) ) {
4042 // delete empty option from original select to avoid duplication
@@ -43,10 +45,10 @@ function initTomSelect(parent) {
4345 new TomSelect ( this , {
4446 plugins : plugins ,
4547 allowEmptyOption : hasBlankOption ( this ) ,
46- // add search box only for tom-select-ajax
47- controlInput : null ,
48- // we need to display all if we remove search input
48+ controlInput : isMultiple ? undefined : null ,
4949 maxOptions : null ,
50+ loadThrottle : 0 ,
51+ refreshThrottle : 0 ,
5052 onInitialize : function ( ) {
5153 // avoid selecting first option by default
5254 if ( ! hasSelectedOption ( this . input ) ) this . clear ( )
@@ -57,7 +59,7 @@ function initTomSelect(parent) {
5759 } )
5860 } )
5961
60- // Sortable: .tom-select-sortable
62+ // Sortable: .tom-select-sortable (always multiple)
6163 parent . find ( 'select.tom-select-sortable' ) . each ( function ( ) {
6264 if ( this . tomselect ) return
6365
@@ -67,13 +69,11 @@ function initTomSelect(parent) {
6769 // delete empty option from original select to avoid duplication
6870 $el . find ( 'option[value=""]' ) . remove ( )
6971 }
70- if ( $el . data ( 'with-search' ) ) plugins . push ( 'dropdown_input' )
7172 new TomSelect ( this , {
7273 plugins : plugins ,
73- // add search box only for tom-select-ajax
74- controlInput : null ,
75- // we need to display all if we remove search input
7674 maxOptions : null ,
75+ loadThrottle : 0 ,
76+ refreshThrottle : 0 ,
7777 onInitialize : function ( ) {
7878 // avoid selecting first option by default
7979 if ( ! hasSelectedOption ( this . input ) ) this . clear ( )
@@ -98,11 +98,15 @@ function initTomSelect(parent) {
9898 initTomSelectAjaxFillable ( this )
9999 } )
100100
101- // Filter form selects (disable search)
101+ // Filter form selects
102102 parent . find ( 'form.filter_form div.select_and_search > select' ) . each ( function ( ) {
103103 if ( this . tomselect ) return
104104 new TomSelect ( this , {
105+ plugins : [ 'dropdown_input' ] ,
105106 controlInput : null ,
107+ maxOptions : null ,
108+ loadThrottle : 0 ,
109+ refreshThrottle : 0 ,
106110 render : {
107111 item : tomSelectRenderItemFunc
108112 }
0 commit comments