diff options
author | Kyle J. Kemp <kyle@seiyria.com> | 2022-06-10 18:07:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 18:07:19 +0300 |
commit | 9b753303df7da72a1b6f06d3726db9a796f0d2ce (patch) | |
tree | ded4c3e154f1a8bf80059f003fb31f5925f96964 | |
parent | 1d8871d5e5164f2129f16089cc1ddd90523e4a82 (diff) |
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.
-rw-r--r-- | layouts/partials/banner.html | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/layouts/partials/banner.html b/layouts/partials/banner.html index e6a620e..1936158 100644 --- a/layouts/partials/banner.html +++ b/layouts/partials/banner.html @@ -19,6 +19,13 @@ {{ $currentNode := . }} {{ $currentNode.Scratch.Set "pages" .Site.Pages
}} {{ $pages := ($currentNode.Scratch.Get "pages") }}
<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() {
var projects = [
{{ range $pages }}
|