dcadenas / auto_focusable_forms

Plugin to automatically give focus to your Rails forms

This URL has Read+Write access

auto_focusable_forms / README.rdoc
94b32cd9 » dcadenas 2008-10-12 README in RDOC format 1 = auto_focusable_forms
2
3 * http://github.com/dcadenas/auto_focusable_forms
4
5 == DESCRIPTION:
6
7 Install this plugin to automatically give focus to your forms.
8
9 == SYNOPSIS:
10
11 If you have this two forms in your view...
12
13 form_for @user do |f|
14 f.text_field :name
15 f.text_field :surname
16 fields_for @post do |g|
17 g.text_field :title
18 g.text_area :content
19 end
20 end
21
22 form_for @post do |f|
23 f.text_field :title
24 end
25
b48670a5 » dcadenas 2008-10-15 updated README 26 ...you'll see that the name field will have focus. Disabled and readonly fields are ignored.
94b32cd9 » dcadenas 2008-10-12 README in RDOC format 27
28 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:
29
30 form_for @user, :autofocus => false do |f|
31 f.text_field :name
32 f.text_field :surname
33 end
34
35 form_for @post do |f|
36 f.text_field :title
37 f.text_field :content
38 end
39
40 And now the focus will be in the title field.
41
42 See the specs for more examples
43
44 == INSTALL:
45
19e2e2ed » dcadenas 2008-10-19 fixed install instructions 46 $ ruby script/plugin install git://github.com/dcadenas/auto_focusable_forms.git
94b32cd9 » dcadenas 2008-10-12 README in RDOC format 47
48 == LICENSE:
49
50 (The MIT License)
51
52 Copyright (c) 2008 Daniel Cadenas
53
54 Permission is hereby granted, free of charge, to any person obtaining
55 a copy of this software and associated documentation files (the
56 'Software'), to deal in the Software without restriction, including
57 without limitation the rights to use, copy, modify, merge, publish,
58 distribute, sublicense, and/or sell copies of the Software, and to
59 permit persons to whom the Software is furnished to do so, subject to
60 the following conditions:
61
62 The above copyright notice and this permission notice shall be
63 included in all copies or substantial portions of the Software.
64
65 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
66 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
67 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
68 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
69 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
70 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
71 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.