autocomplete: render html server-side.
Render the HTML for autocomplete results server-side instead of in Javascript. This is cleaner than building HTML in Javascript, but it may hurt caching because the HTTP responses are larger. Fixes #4698: user autocomplete contains links to /posts Also fixes a bug where tag counts in the autocomplete menu were different from tag counts displayed elsewhere because of differences in rounding.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<ul>
|
||||
<% autocomplete_results.each do |result| %>
|
||||
<%= tag.li class: "ui-menu-item", "data-autocomplete-type": result.type, "data-autocomplete-antecedent": result.antecedent, "data-autocomplete-value": result.value, "data-autocomplete-category": result.category, "data-autocomplete-post-count": result.post_count do %>
|
||||
<div class="ui-menu-item-wrapper" tabindex="-1">
|
||||
<%= link_to_result result do %>
|
||||
<% if result.antecedent.present? %>
|
||||
<span class="autocomplete-antecedent"><%= result.antecedent.tr("_", " ") %></span>
|
||||
<span class="autocomplete-arrow">→</span>
|
||||
<% end %>
|
||||
|
||||
<%= result.label %>
|
||||
<% end %>
|
||||
|
||||
<% if result.post_count %>
|
||||
<%= tag.span humanized_number(result.post_count), class: "post-count", style: "float: right;" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
Reference in New Issue
Block a user