getgrav / grav-plugin-simplesearch

Grav SimpleSearch Plugin
https://getgrav.org
MIT License
44 stars 55 forks source link

FIx for JS error caused by pull request #156 #160

Closed newkind closed 6 years ago

newkind commented 6 years ago

1e381a79912987693fca3f551a18d3a0f7b229f6

tcyrus commented 6 years ago

This plugin is currently broken (when using the default template and js) due to the changes implemented in #156 (1e381a79912987693fca3f551a18d3a0f7b229f6). The reason for this is the JavaScript selector (in js/simplesearch.js) was not updated to reflect the change in name attribute of the input.

rhukster commented 6 years ago

ok this has really caused some confusion.

The field should be searchfield.

per the included partials/simplesearch_searchbox.html.twig:

{% set min_chars = config.get('plugins.simplesearch.min_query_length', 3) %}
<div class="search-wrapper">
    <form name="search" data-simplesearch-form>
        <input
            name="searchfield"
            class="search-input"
...

with the appropriate JS:

var fields = document.querySelectorAll('input[name="searchfield"][data-search-input]');