mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-28 20:52:21 +01:00
adds minLength #3960
This commit is contained in:
parent
8281a9023a
commit
fae6c36874
5
docs/assets/js/bootstrap-typeahead.js
vendored
5
docs/assets/js/bootstrap-typeahead.js
vendored
@ -81,7 +81,7 @@
|
||||
|
||||
this.query = this.$element.val()
|
||||
|
||||
if (!this.query) {
|
||||
if (!this.query || this.query.length < this.options.minLength) {
|
||||
return this.shown ? this.hide() : this
|
||||
}
|
||||
|
||||
@ -279,12 +279,13 @@
|
||||
, items: 8
|
||||
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
||||
, item: '<li><a href="#"></a></li>'
|
||||
, minLength: 1
|
||||
}
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead
|
||||
|
||||
|
||||
/* TYPEAHEAD DATA-API
|
||||
/* TYPEAHEAD DATA-API
|
||||
* ================== */
|
||||
|
||||
$(function () {
|
||||
|
5
docs/assets/js/bootstrap.js
vendored
5
docs/assets/js/bootstrap.js
vendored
@ -1690,7 +1690,7 @@
|
||||
|
||||
this.query = this.$element.val()
|
||||
|
||||
if (!this.query) {
|
||||
if (!this.query || this.query.length < this.options.minLength) {
|
||||
return this.shown ? this.hide() : this
|
||||
}
|
||||
|
||||
@ -1888,12 +1888,13 @@
|
||||
, items: 8
|
||||
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
||||
, item: '<li><a href="#"></a></li>'
|
||||
, minLength: 1
|
||||
}
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead
|
||||
|
||||
|
||||
/* TYPEAHEAD DATA-API
|
||||
/* TYPEAHEAD DATA-API
|
||||
* ================== */
|
||||
|
||||
$(function () {
|
||||
|
2
docs/assets/js/bootstrap.min.js
vendored
2
docs/assets/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1543,6 +1543,12 @@ $('.carousel').carousel({
|
||||
<td>8</td>
|
||||
<td>The max number of items to display in the dropdown.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>minLength</td>
|
||||
<td>number</td>
|
||||
<td>1</td>
|
||||
<td>The minimum character length needed before triggering autocomplete suggestions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>matcher</td>
|
||||
<td>function</td>
|
||||
|
6
docs/templates/pages/javascript.mustache
vendored
6
docs/templates/pages/javascript.mustache
vendored
@ -1474,6 +1474,12 @@ $('.carousel').carousel({
|
||||
<td>8</td>
|
||||
<td>{{_i}}The max number of items to display in the dropdown.{{/i}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{_i}}minLength{{/i}}</td>
|
||||
<td>{{_i}}number{{/i}}</td>
|
||||
<td>{{_i}}1{{/i}}</td>
|
||||
<td>{{_i}}The minimum character length needed before triggering autocomplete suggestions{{/i}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{_i}}matcher{{/i}}</td>
|
||||
<td>{{_i}}function{{/i}}</td>
|
||||
|
5
js/bootstrap-typeahead.js
vendored
5
js/bootstrap-typeahead.js
vendored
@ -81,7 +81,7 @@
|
||||
|
||||
this.query = this.$element.val()
|
||||
|
||||
if (!this.query) {
|
||||
if (!this.query || this.query.length < this.options.minLength) {
|
||||
return this.shown ? this.hide() : this
|
||||
}
|
||||
|
||||
@ -279,12 +279,13 @@
|
||||
, items: 8
|
||||
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
||||
, item: '<li><a href="#"></a></li>'
|
||||
, minLength: 1
|
||||
}
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead
|
||||
|
||||
|
||||
/* TYPEAHEAD DATA-API
|
||||
/* TYPEAHEAD DATA-API
|
||||
* ================== */
|
||||
|
||||
$(function () {
|
||||
|
20
js/tests/unit/bootstrap-typeahead.js
vendored
20
js/tests/unit/bootstrap-typeahead.js
vendored
@ -181,4 +181,24 @@ $(function () {
|
||||
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
|
||||
test("should start querying when minLength is met", function () {
|
||||
var $input = $('<input />').typeahead({
|
||||
source: ['aaaa', 'aaab', 'aaac'],
|
||||
minLength: 3
|
||||
})
|
||||
, typeahead = $input.data('typeahead')
|
||||
|
||||
$input.val('aa')
|
||||
typeahead.lookup()
|
||||
|
||||
equals(typeahead.$menu.find('li').length, 0, 'has 0 items in menu')
|
||||
|
||||
$input.val('aaa')
|
||||
typeahead.lookup()
|
||||
|
||||
equals(typeahead.$menu.find('li').length, 3, 'has 3 items in menu')
|
||||
|
||||
typeahead.$menu.remove()
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user