Just commited a Rails plugin (my first one, yay!!) to give automatic focus to the first input of the first form in each of your views.
Of course you can disable this behaviour but I think that having focus in the first input by default can be very useful.
You can read more in the project page here.
Friday, October 10, 2008
Subscribe to:
Post Comments (Atom)





4 comments:
Hi,
If a field already has a value, the current code puts the cursor at the beginning of the field. I patched line 25 of lib/autofocusable.rb to look like this:
@template.instance_variable_set('@focus_was_set', @template.javascript_tag("document.getElementById('#{tag_id(method_name)}').focus();\n document.getElementById('#{tag_id(method_name)}').value = document.getElementById('#{tag_id(method_name)}').value;"))
It is a cross-browser trick to make sure the cursor gets set at the end of the text field.
Thanks for the patch! I think it's useful, I will add it to the plugin as soon as I have some free time.
Your change is pushed, thank you and sorry for the delay.
I wish I knew your name so I could at least add you in the commit info!
Post a Comment