hi, Is there any way to set focus in a particular field, after validation in rails?? or we have to use only javascript. For example., validates_presence_of :username (assume there is no username given) after validation, how can i set focus in that particular username textbox. is there any way in rails or should i use javascript. Thanks. -------- my ror blog http://www.srikanthjeeva.blogspot.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No idea in ruby, but you can use JS for this.. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ya i can do it with JS, any way in rails?? -------- my ror blog http://www.srikanthjeeva.blogspot.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-03 07:57 UTC
Re: Validation - set focus
On 3 Mar., 08:41, Srikanth Jeeva <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> ya i can do it with JS, > any way in rails??You can approach this by making Rails generate some JavaScript for you. I''ve put together a little example: http://pastie.org/405697 Call the method somewhere in your view and the method _should_ make some JavaScript to focus on the first field in your form that has errors. Keep in mind that it''s untested so if it doesn''t work you might need to fix an error or two, or maybe ask for help here. -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-03 09:07 UTC
Re: Validation - set focus
On 3 Mar., 08:57, "ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org" <ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org> wrote:> > ya i can do it with JS, > > any way in rails?? > > You can approach this by making Rails generate some JavaScript for > you.I''ve revised the example a bit. This works perfectly for me. Feel free to try it out: http://pastie.org/405733 -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-03 09:21 UTC
Re: Validation - set focus
On 3 Mar., 10:07, "ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org" <ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org> wrote:> I''ve revised the example a bit. This works perfectly for me. Feel free > to try it out:http://pastie.org/405733I need to mention that in the latest example (http://pastie.org/ 405733) I''m also overriding the #error_messages_for method, so now you can actully focus on the first field that has errors automatically. The only thing you need to change is your application layout. Put: <%= yield :head %> ... just before </head>. And then of course add the two methods to your application helper file. Hope it helps... :) -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
really thanks man.... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---