mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-12 16:26:37 +00:00
Do not try to highlight suggestion if current value is empty, resolves #434
Prevents inserting strong tag after each character when input value is empty.
This commit is contained in:
parent
fef68b6e4c
commit
e572acf56f
@ -127,8 +127,13 @@
|
||||
$.Autocomplete = Autocomplete;
|
||||
|
||||
Autocomplete.formatResult = function (suggestion, currentValue) {
|
||||
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
|
||||
// Do not replace anything if there current value is empty
|
||||
if (!currentValue) {
|
||||
return suggestion.value;
|
||||
}
|
||||
|
||||
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
|
||||
|
||||
return suggestion.value
|
||||
.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>')
|
||||
.replace(/&/g, '&')
|
||||
|
Loading…
Reference in New Issue
Block a user