Skip to content

Commit ff0745a

Browse files
committed
Added "addPrecedence" option (selectize#118).
1 parent 7f450db commit ff0745a

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

docs/usage.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ $(function() {
101101
<td valign="top"><code>string</code></td>
102102
<td valign="top"><code>null</code></td>
103103
</tr>
104+
<tr>
105+
<td valign="top"><code>addPrecedence</code></td>
106+
<td valign="top">Sets if the "Add..." option should be the default selection in the dropdown.</td>
107+
<td valign="top"><code>boolean</code></td>
108+
<td valign="top"><code>false</code></td>
109+
</tr>
104110
<tr>
105111
<th valign="top" colspan="4" align="left"><a href="#data_searching" name="data_searching">Data / Searching</a></th>
106112
</tr>

src/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Selectize.defaults = {
1010
maxOptions: 1000,
1111
maxItems: null,
1212
hideSelected: null,
13+
addPrecedence: false,
1314
preload: false,
1415

1516
scrollDuration: 60,

src/selectize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,10 +974,10 @@ $.extend(Selectize.prototype, {
974974
self.hasOptions = results.items.length > 0 || hasCreateOption;
975975
if (self.hasOptions) {
976976
if (results.items.length > 0) {
977-
if ($create) {
977+
if ($create && !self.settings.addPrecedence) {
978978
$active = self.getAdjacentOption($create, 1);
979979
} else {
980-
$active = $dropdown_content.find("[data-selectable]").first();
980+
$active = $dropdown_content.find('[data-selectable]:first');
981981
}
982982
} else {
983983
$active = $create;

0 commit comments

Comments
 (0)