Hi, 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! Thanks, Ali --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> ** 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): <%= javascript_tag "document.myform.elements[0].focus();" %>> 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!http://www.w3schools.com/js/default.asp http://www.w3schools.com/htmldom/default.asp http://www.w3schools.com/dhtml/default.asp http://www.sergiopereira.com/articles/prototype.js.html http://script.aculo.us/ -philip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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: <%= javascript_tag "document.form.focusFirstElement(form);" %> But that didn''t work either. Ruby/Rails frustrates me so much sometimes. I have the line of code in my _form at the end. Any other suggestions? Thanks again!! ~Ali --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
"report" is the name of my form. I tried it that way too, but it still didn''t like it. Ali Williams Technology Systems Developer II Washoe County Technology Services 775 328-3720 -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Philip Hallstrom Sent: Tuesday, January 16, 2007 4:01 PM To: Ruby on Rails: Talk Subject: [Rails] Re: Tips and Tricks> 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: > > <%= javascript_tag "document.form.focusFirstElement(form);" %>Is "form" the name of your form? I''ve never used focusFirstElement before...> > But that didn''t work either. Ruby/Rails frustrates me so much > sometimes. > > I have the line of code in my _form at the end. Any othersuggestions?> > Thanks again!! ~Ali > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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: > > <%= javascript_tag "document.form.focusFirstElement(form);" %>Is "form" the name of your form? I''ve never used focusFirstElement before...> > But that didn''t work either. Ruby/Rails frustrates me so much > sometimes. > > I have the line of code in my _form at the end. Any other suggestions? > > Thanks again!! ~Ali > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/17/07, Ali <awilliams-KQhSGARDxiOeQVqA2Ba1Pg@public.gmane.org> wrote:> > 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: > > <%= javascript_tag "document.form.focusFirstElement(form);" %> > > But that didn''t work either. Ruby/Rails frustrates me so much > sometimes. > > I have the line of code in my _form at the end. Any other suggestions? > > Thanks again!! ~Ali >Try document.forms[0].elements[0].focus(); 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. Cheers, --max --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---