DISQUS
Returning?
Login
Website
http://buildingbrowsergames.com
Original page
http://buildingbrowsergames.com/2008/09/03/making-your-forms-auto-focus-ruby-on-rails/
Subscribe
All Comments
Community
Top Commenters
Popular Threads
Building Browsergames
: Making Your Forms Auto-Focus (Ruby on Rails)
jake
· 1 year ago
in jQuery you can also write it like:
<pre>
$(window).ready(function(){
$("input:nth-child(0)").focus()
})
</pre>
with Prototype you can do:
<pre>
document.observe("window:loaded", function() {
// initially hide all containers for tab content
$('user_login').focus()
});
</pre>
Marko
· 1 year ago
People that need also to position the cursor should take a look at
http://developer.mozilla.org/en/XUL/Method/setS...
and
http://msdn.microsoft.com/en-us/library/ms53640...
Nisha
· 10 months ago
It worked for me. Thank You
elecnix
· 9 months ago
It would be nice if the FormHelper would allow passing an option to text_field to automagically add this JS to the page.
<pre>
$(window).ready(function(){
$("input:nth-child(0)").focus()
})
</pre>
with Prototype you can do:
<pre>
document.observe("window:loaded", function() {
// initially hide all containers for tab content
$('user_login').focus()
});
</pre>