Hi - I have the following problem: my app has a form that acts as a filter to a table on the page, so that the user can search any value in the table (via text box) or use select lists for more specific search. The form is being observed by an observe_form helper that runs every 1-2 seconds or so. It''s all still in testing. I noticed that when I hit return while in the textbox, the form posts and redirects me to an action unknown page. I want to remove that functionality so that hitting enter wont do anything -- any idea how to do it? Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
How about removing form tags - just have the field and the observe_field .... this might not be valid html - not sure about that. Ivor On Mon, Dec 29, 2008 at 12:21 PM, sa 125 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Hi - I have the following problem: my app has a form that acts as a > filter to a table on the page, so that the user can search any value in > the table (via text box) or use select lists for more specific search. > The form is being observed by an observe_form helper that runs every 1-2 > seconds or so. It''s all still in testing. > > I noticed that when I hit return while in the textbox, the form posts > and redirects me to an action unknown page. I want to remove that > functionality so that hitting enter wont do anything -- any idea how to > do it? > > Thanks > -- > 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 -~----------~----~----~----~------~----~------~--~---
Ivor Paul wrote:> How about removing form tags - just have the field and the observe_field > .... this might not be valid html - not sure about that.<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>untitled</title> </head> <body> <div> <label for="test">Test</label><input type="text" name="test" value="" id="test" /> </div> </body> </html> ------------ The above code passes the W3C validator for XHTML 1.0 Strict and XHTML 1.1. Notice that the <div> surrounding the <label> and <input> was necessary to pass XHTML Strict, but was not required for XHTML 1.0 Transitional. Other surrounding tags besides <div> work as well, but the <label> and <input> tags must be contained by something. Example (this is INVALID!): ------------------ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>untitled</title> </head> <body> <label for="test">Test</label><input type="text" name="test" value="" id="test" /> </body> </html> W3C Validator: Line 10, Column 19: document type does not allow element "label" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset" start-tag. ------------------ -- 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 -~----------~----~----~----~------~----~------~--~---
I believe if you put a textarea in your form, the browser will not submit the form if you hit the enter key. It depends on which browser you are using though. On Mon, Dec 29, 2008 at 11:18 AM, Robert Walker < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Ivor Paul wrote: > > How about removing form tags - just have the field and the observe_field > > .... this might not be valid html - not sure about that. > > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> > <head> > <title>untitled</title> > </head> > <body> > <div> > <label for="test">Test</label><input type="text" name="test" > value="" id="test" /> > </div> > </body> > </html> > > ------------ > > The above code passes the W3C validator for XHTML 1.0 Strict and XHTML > 1.1. Notice that the <div> surrounding the <label> and <input> was > necessary to pass XHTML Strict, but was not required for XHTML 1.0 > Transitional. Other surrounding tags besides <div> work as well, but the > <label> and <input> tags must be contained by something. > > Example (this is INVALID!): > ------------------ > <?xml version="1.0" encoding="UTF-8"?> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> > <head> > <title>untitled</title> > </head> > <body> > <label for="test">Test</label><input type="text" name="test" value="" > id="test" /> > </body> > </html> > > W3C Validator: > Line 10, Column 19: document type does not allow element "label" here; > missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", > "div", "address", "fieldset" start-tag. > ------------------ > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Using and developing exclusively for firefox -- one of the benefits of building a site that''ll only be run in an office intranet :) I''ll give those a try - thanks. -- 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 -~----------~----~----~----~------~----~------~--~---
lucky you :) kudos to the staff for all using firefox On Tue, Dec 30, 2008 at 11:26 AM, sa 125 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > Using and developing exclusively for firefox -- one of the benefits of > building a site that''ll only be run in an office intranet :) > > I''ll give those a try - thanks. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Create a form without a submit tag. Put in another control on the web page that does $(''id_of_my_form'').submit(); using a javascript onclick event or whatever. Regards, Mukund sa 125 wrote:> Hi - I have the following problem: my app has a form that acts as a > filter to a table on the page, so that the user can search any value in > the table (via text box) or use select lists for more specific search. > The form is being observed by an observe_form helper that runs every 1-2 > seconds or so. It''s all still in testing. > > I noticed that when I hit return while in the textbox, the form posts > and redirects me to an action unknown page. I want to remove that > functionality so that hitting enter wont do anything -- any idea how to > do it? > > Thanks > -- > 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 -~----------~----~----~----~------~----~------~--~---
You can add Javascript to check for the value of the key pressed and ignore it if it is the Enter key. I had to do the exact same thing for the Backspace key not long ago, which was working as the Back icon in some instances. I have a sample but not here. I could give it to you if you still need it tonight when I get home. Pepe On Dec 30, 5:16 am, Mukund <marut...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Create a form without a submit tag. Put in another control on the > web page that does $(''id_of_my_form'').submit(); using a javascript > onclick event or whatever. > > Regards, > Mukund > > sa 125 wrote: > > Hi - I have the following problem: my app has a form that acts as a > > filter to a table on the page, so that the user can search any value in > > the table (via text box) or use select lists for more specific search. > > The form is being observed by an observe_form helper that runs every 1-2 > > seconds or so. It''s all still in testing. > > > I noticed that when I hit return while in the textbox, the form posts > > and redirects me to an action unknown page. I want to remove that > > functionality so that hitting enter wont do anything -- any idea how to > > do it? > > > Thanks > > -- > > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
pepe wrote:> You can add Javascript to check for the value of the key pressed and > ignore it if it is the Enter key. I had to do the exact same thing for > the Backspace key not long ago, which was working as the Back icon in > some instances. > > I have a sample but not here. I could give it to you if you still need > it tonight when I get home. > > Pepedocument.onkeypress = function(e) { if (e.keyCode == 13) { return false; } key code value is 13 for "Enter" if you give return false, it will disable the default property of Key. -- 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 -~----------~----~----~----~------~----~------~--~---
Mukund wrote:> Create a form without a submit tag. Put in another control on the > web page that does $(''id_of_my_form'').submit(); using a javascript > onclick event or whatever. > > Regards, > MukundActually, the form doesn''t have a submit tag in it, but 2 selection lists and a text field (it''s a search/filter form). The submission happens when you hit enter whilst inside the text field -- I think it''s something most people do when searching something > think of every visit you made to a search engine''s page... Rails form_for might have this built in, since it immediately looks for ''create'' action when hitting enter inside the text field. I thought about simply redirecting it to the same action that filters the form (which is actually called via observe_form tag nearby). I''m very new to rails, so I''m not sure how to call the action while retaining the same view. Here''s a brief rundown of my code: # view <% form_for :person, :html => { :id => ''people_form'' } -%> <%= f.select :id, @people.collect {|p| [p.name, p.id]} %> <%= f.select :gender, [[''Male'',''M''],[''Female'',''F'']] %> <%= f.text_field :search, :size => 20 %> <% end -%> <%= observe_form :people_form, :frequency => 2, :update => ''people_table'', :url => { :action => ''search_form'', :only_path => false } %> <div id="people_table"> <table> <%= render :partial => ''person'' %> <!--people rows are drawn from here --> </table> </div> # controller def search_form #... get all search params and store in cond @people = Person.find(:all, :conditions => cond) render :partial => ''person'' if request.xml_http_request? end How would I call the search_form function on form submit resulting in the same view being rendered (similar to what observe_form does)? I tried adding :action => ''search_form'' to the form_for tag, but it then looks for a view of the same name.. -- 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 -~----------~----~----~----~------~----~------~--~---
form_for results in a POST operation. You are checking for request.xhr? in your controller to render the partial. Use remote_form_for instead to get a XHR request. Pressing an enter key in a text field doesn''t submit a form. The tags don''t add that in. Regards, Mukund On Jan 7, 4:15 pm, Shilo Ayalon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Mukund wrote: > > Create a form without a submit tag. Put in another control on the > > web page that does $(''id_of_my_form'').submit(); using a javascript > > onclick event or whatever. > > > Regards, > > Mukund > > Actually, the form doesn''t have a submit tag in it, but 2 selection > lists and a text field (it''s a search/filter form). The submission > happens when you hit enter whilst inside the text field -- I think it''s > something most people do when searching something > think of every visit > you made to a search engine''s page... Rails form_for might have this > built in, since it immediately looks for ''create'' action when hitting > enter inside the text field. > > I thought about simply redirecting it to the same action that filters > the form (which is actually called via observe_form tag nearby). I''m > very new to rails, so I''m not sure how to call the action while > retaining the same view. Here''s a brief rundown of my code: > > # view > > <% form_for :person, :html => { :id => ''people_form'' } -%> > <%= f.select :id, @people.collect {|p| [p.name, p.id]} %> > <%= f.select :gender, [[''Male'',''M''],[''Female'',''F'']] %> > <%= f.text_field :search, :size => 20 %> > <% end -%> > > <%= observe_form :people_form, :frequency => 2, :update => > ''people_table'', > :url => { :action => ''search_form'', :only_path => false > > } %> > > <div id="people_table"> > <table> > <%= render :partial => ''person'' %> <!--people rows are drawn from > here --> > </table> > </div> > > # controller > > def search_form > #... get all search params and store in cond > @people = Person.find(:all, :conditions => cond) > render :partial => ''person'' if request.xml_http_request? > end > > How would I call the search_form function on form submit resulting in > the same view being rendered (similar to what observe_form does)? I > tried adding :action => ''search_form'' to the form_for tag, but it then > looks for a view of the same name.. > > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mukund wrote:> form_for results in a POST operation. You are checking for > request.xhr? in your controller to render the partial. Use > remote_form_for instead to get a XHR request. > > Pressing an enter key in a text field doesn''t submit a form. The tags > don''t add that in. > > Regards, > Mukund > >I changed the form_for to remote_form_for, and this disabled the search for the new view - Thanks. Using firebug I still see it''s getting a 404 error when I hit enter in the text field. so I''m not sure what''s submitting the form on enter.. Also, I''m afraid I''m not sure what you mean with the XHR part - should I just change render :partial => ''person'' if request.xml_http_request? to render :partial => ''person'' now that remote_form_for submits an ajax request? Thanks for your help! -- 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 -~----------~----~----~----~------~----~------~--~---