Autofocus the search field on the index page
This commit is contained in:
parent
00548468ac
commit
bdc536d126
2 changed files with 7 additions and 1 deletions
|
@ -128,4 +128,10 @@ $(document).ready(function () {
|
|||
if ($("#query").val()) {
|
||||
$("#search_form").submit();
|
||||
}
|
||||
|
||||
// Focus the search field for browsers that don't support
|
||||
// the HTML5 'autofocus' attribute
|
||||
if (!("autofocus" in document.createElement("input"))) {
|
||||
$("#query").focus();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div id="search_field">
|
||||
<%= form_tag url_for(:controller => :geocoder, :action => :search), :id => "search_form" do %>
|
||||
<%= submit_tag t('site.search.submit_text') %>
|
||||
<%= text_field_tag :query, h(params[:query]), :tabindex => "1", :placeholder => t('site.search.search') %>
|
||||
<%= text_field_tag :query, h(params[:query]), :tabindex => "1", :placeholder => t('site.search.search'), :autofocus => "autofocus" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue