Files
danbooru/app/views/posts/partials/common/_search.html.erb
evazion 4631262374 Fix broken tag autocomplete on multiple pages.
Mark all tag <input>s with a `data-autocomplete` attribute, instead of
hardcoding a list of html IDs to autocomplete in javascript.

This way should be less error prone. It fixes autocomplete in several places:

* Autocomplete for the search box on /posts didn't work in the
  responsive layout. This was because /posts has two search boxes that
  both have the id `tags`: one in the normal sidebar, and one in the
  responsive tag list. $("#tags") only initialized autocomplete on the
  first one.

* Autocomplete didn't work on the aliases or implications pages. This
  was due to selecting the wrong html ids.
2017-04-22 15:24:03 -05:00

31 lines
1.1 KiB
Plaintext

<!--
- path
- tags
-->
<section id="search-box">
<h1>Search</h1>
<%= form_tag(path, :method => "get") do %>
<%= text_field_tag("tags", tags, :size => 20, :id => tags_dom_id, :data => { :autocomplete => "tag-query" }) %>
<% if params[:raw] %>
<%= hidden_field_tag :raw, params[:raw] %>
<% end %>
<% if params[:random] %>
<%= hidden_field_tag :random, params[:random] %>
<% end %>
<%= hidden_field_tag "ms", "1" %>
<%= submit_tag "Go", :name => nil %>
<%= submit_tag "+", :id => "expand-search", "data-jq-dropdown" => "#search-dropdown" %>
<div id="search-dropdown" class="jq-dropdown jq-dropdown-tip">
<ul class="jq-dropdown-menu">
<% if SavedSearch.enabled? && CurrentUser.show_saved_searches? %>
<li><%= link_to "Save search", saved_searches_path, :id => "save-search" %></li>
<% end %>
<li><%= link_to "Search wiki", wiki_pages_path, :id => "wiki-search" %></li>
<li><%= link_to "Search artists", artists_path, :id => "artist-search" %></li>
</ul>
</div>
<% end %>
</section>