Plugins - Auto Focusable Forms
Add to favoritesExample:
If you have this two forms in your view…
form_for @user do |f|
f.text_field :name
f.text_field :surname
fields_for @post do |g|
g.text_field :title
g.text_area :content
end
end
form_for @post do |f|
f.text_field :title
end
…you’ll see that the name field will have focus.
If you want to disable this behaviour just add :autofocus => false and the form will have the original Rails behaviour. So if for example you want to give focus to the second form in your view you’d just disable autofocus in the first form:
form_for @user, :autofocus => false do |f|
f.text_field :name
f.text_field :surname
end
form_for @post do |f|
f.text_field :title
f.text_field :content
end
And now the focus will be in the title field.
See the specs for more examples
Install:
$ sudo ruby script/plugin install git://github.com/dcadenas/auto_focusable_forms.git
http://github.com/dcadenas/auto_focusable_forms
git://github.com/dcadenas/auto_focusable_forms.git
Rails' (MIT)
View Extensions
