forked from TrueCloudLab/dot-hugo
add autocomplete filtering on label AND value
as it is, trying to filter by the items in the array is frustrating as only the value is filtered on. this change allows for filtering on both.
This commit is contained in:
parent
1d8871d5e5
commit
9b753303df
1 changed files with 7 additions and 0 deletions
|
@ -19,6 +19,13 @@
|
||||||
{{ $currentNode := . }} {{ $currentNode.Scratch.Set "pages" .Site.Pages
|
{{ $currentNode := . }} {{ $currentNode.Scratch.Set "pages" .Site.Pages
|
||||||
}} {{ $pages := ($currentNode.Scratch.Get "pages") }}
|
}} {{ $pages := ($currentNode.Scratch.Get "pages") }}
|
||||||
<script>
|
<script>
|
||||||
|
$.ui.autocomplete.filter = function (array, term) {
|
||||||
|
var matcher = new RegExp('(^| )' + $.ui.autocomplete.escapeRegex(term), 'i');
|
||||||
|
return $.grep(array, function (value) {
|
||||||
|
return matcher.test(value.label) || matcher.test(value.value) || matcher.test(value);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var projects = [
|
var projects = [
|
||||||
{{ range $pages }}
|
{{ range $pages }}
|
||||||
|
|
Loading…
Reference in a new issue