I have successfully implemented my first Ruby on Rails application!
Now, my users are of course wanting piddly little things like:
** Pressing "enter" to save the form - currently when they press
enter it does not save and moves away from the form causing them to
have to re-enter data.
** Having the cursor default to the first field in the form when the
form opens.
Where is a good place to find out how to do little things like this?
As always, any advice or suggestion is welcome and appreciated!
** Pressing "enter" to save the form - currently when they press
enter it does not save and moves away from the form causing them to
have to re-enter data.
Odd... that should just happen by default...
** Having the cursor default to the first field in the form when the
form opens.
Let's say your form has the attribute name='myform' then you could do something like this (after your form ends):
Thanks so much for the reply. I tried the code you suggested and the
form just does not want to set focus. I tried those sites you sent as
well, and tried changing the code to:
Thanks so much for the reply. I tried the code you suggested and the
form just does not want to set focus. I tried those sites you sent as
well, and tried changing the code to:
for the first form element of the first form on the page.
Or, if you want to focus on a particular named input field:
$('user_name').focus();
This requires protoype.js.
BTW, this has nothing to do with Rails or Ruby. This is really basic
javascript stuff - there are plenty of really good resources and
tutorials out there.