DISQUS

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 · 9 months ago
    It worked for me. Thank You
  • elecnix · 8 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.