File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -154,15 +154,18 @@ $(function() {
154
154
</tr>
155
155
<tr>
156
156
<td valign="top"><code>sortField</code></td>
157
- <td valign="top">The name of the property to sort by. This is only used when the score of two or more items is identical.</td>
158
- <td valign="top"><code>string</code></td>
159
- <td valign="top"><code>null</code></td>
160
- </tr>
161
- <tr>
162
- <td valign="top"><code>sortDirection</code></td>
163
- <td valign="top">Sort direction ("asc" or "desc").</td>
164
- <td valign="top"><code>string</code></td>
165
- <td valign="top"><code>'asc'</code></td>
157
+ <td valign="top">
158
+ A single field or an array of fields to sort by. Each item in the array should be an object containing at
159
+ least a "field" property. Optionally, "direction" can be set to "asc" or "desc". The
160
+ order of the array defines the sort precedence.<br><br>
161
+
162
+ Unless present, a special "$score" field will be automatically added to the beginning
163
+ of the sort list. This will make results sorted primarily by match quality (descending).<br><br>
164
+
165
+ For more information, see the <a href="https://github.com/brianreavis/sifter.js#sifterjs">sifter documentation</a>.
166
+ </td>
167
+ <td valign="top"><code>string|array</code></td>
168
+ <td valign="top"><code>'$order'</code></td>
166
169
</tr>
167
170
<tr>
168
171
<td valign="top"><code>searchField</td>
Original file line number Diff line number Diff line change @@ -18,13 +18,13 @@ Selectize.defaults = {
18
18
19
19
dataAttr : 'data-data' ,
20
20
optgroupField : 'optgroup' ,
21
- sortField : { field : '$order' } ,
22
- sortDirection : 'asc' ,
23
21
valueField : 'value' ,
24
22
labelField : 'text' ,
25
23
optgroupLabelField : 'label' ,
26
24
optgroupValueField : 'value' ,
27
25
optgroupOrder : null ,
26
+
27
+ sortField : '$order' ,
28
28
searchField : [ 'text' ] ,
29
29
searchConjunction : 'and' ,
30
30
Original file line number Diff line number Diff line change @@ -829,11 +829,15 @@ $.extend(Selectize.prototype, {
829
829
*/
830
830
getSearchOptions : function ( ) {
831
831
var settings = this . settings ;
832
+ var sort = settings . sortField ;
833
+ if ( typeof sort === 'string' ) {
834
+ sort = { field : sort } ;
835
+ }
832
836
833
837
return {
834
838
fields : settings . searchField ,
835
839
conjunction : settings . searchConjunction ,
836
- sort : settings . sortField
840
+ sort : sort
837
841
} ;
838
842
} ,
839
843
You can’t perform that action at this time.
0 commit comments