use autofocus attribute for text boxes instead of javascript

This commit is contained in:
joshua stein 2012-09-18 09:44:22 -05:00
parent 42150c8a56
commit d5cf5bc4f5
2 changed files with 3 additions and 16 deletions

View file

@ -6,7 +6,7 @@
<%= form_tag login_url do %>
<p>
<%= label_tag :email, "E-mail or Username:" %>
<%= text_field_tag :email, "", :size => 30 %>
<%= text_field_tag :email, "", :size => 30, :autofocus => "autofocus" %>
<br />
<%= label_tag :password, "Password:" %>
@ -24,9 +24,3 @@
</p>
<% end %>
</div>
<script>
$(document).ready(function() {
$("#email").focus();
});
</script>

View file

@ -5,7 +5,8 @@
<%= form_tag "/search", :method => :get do %>
<div class="boxline">
<%= text_field_tag "q", @search.q, :size => 40 %>
<%= text_field_tag "q", @search.q, { :size => 40 }.
merge(@search.q.present? ? {} : { :autofocus => "autofocus" }) %>
<input type="submit" value="Search">
</div>
@ -43,14 +44,6 @@
<label for="search_order_points" class="normal">Points</label>
</div>
<% end %>
<% if !@search.q.present? %>
<script>
$(document).ready(function() {
$("#q").focus();
});
</script>
<% end %>
</div>
<% if @search.results.any? %>