Has anyone else noticed that buttons rendered with button_to_function in Safari don''t work when you hit return? Works find in firefox. Is there a know work around? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hm.. I just did a quick test and when I tabbed to the button and pressed return, it submitted the form. Maybe you have something else amiss? Safari 3.0.4 (523.12) on Mac OS X 10.4.11 and Windows XP SP2. Peace, Phillip On Dec 9, 2007, at 9:11 PM, Pat wrote:> > Has anyone else noticed that buttons rendered with button_to_function > in Safari don''t work when you hit return? Works find in firefox. Is > there a know work around? > >--~--~---------~--~----~------------~-------~--~----~ 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 Dec 9, 2007, at 9:11 PM, Pat wrote:> > Has anyone else noticed that buttons rendered with button_to_function > in Safari don''t work when you hit return? Works find in firefox. Is > there a know work around? > >Gack... Sorry, Pat. Just looked a little closer and saw that you said button_to_function, not button_to. That''s a different story, but I do have some information for you. I ran into the same problem last night and it''s because there''s no form element. According to someone on the web-dev Apple list, it''s a bug in Safari (which I have not yet filed...Maybe we both should :) ). You can get around it in one of two ways: 1) put a form around the <input> 2) change it to <button>...</button> Granted, that means you will have to create your html without using button_to_function, but it will work. Here''s the text an the exchange I had last night/this morning: ============================================== Thank you Alexey and Tom. I tried two things: 1) changing <input type="button" ...> to <button></button> and 2) putting a <form onclick="say_hi(); return false;"> around the input. Both achieved the desired result, but I have to ask which way is more correct? My specific scenario is I have a login form with two buttons, one for "Login" and one for "Forgot Password", each calling a JavaScript function. In the case of Forgot Password, it''s a simple redirect with window.location = url; But for the login form, I submit the username and password via Prototype and AJAX, so when the user enters incorrect login credentials, I update the specific portion of the screen by rendering a partial (this is a Rails app). I chose to do this so I wouldn''t have to redraw the whole page again because it has flash animations and graphics (trying to keep it snappy). In addition to the previous two examples, I suppose there is a third possibility: 3) Use two forms, one for the login piece and one for the Forgot Password button Which way would be considered the closest to correct? Peace, Phillip On Dec 9, 2007, at 6:02 AM, Tómas Árnason wrote: Try using a button-tag instead, might work. As you don''t have a form- element surrounding the input-button. Also, check out the JavaScript console in Safari and check the output... Tom On Dec 9, 2007, at 2:33 AM, Alexey Proskuryakov wrote: on 09.12.2007 07:37, Phillip Koebbe at phillipkoebbe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: When the button is highlighted, IE 6 and FireFox 2.0.0.11 (Windows and Mac) both fire the onclick event when the Enter/Return key is pressed. Safari 3 (neither Windows or Mac) doesn''t. Safari simulates onclick on form''s submit element, not the button (and if there is no submit, it doesn''t simulate a click). Please file a bug via <http://bugs.webkit.org>! <button> doesn''t have this problem AFAICT. Is there some special way of getting that to work in Safari without resorting to trapping the key in an onkeypress event? Besides using <button>, I would suggest onkeydown over onkeypress, although in this specific case it doesn''t make a difference. - WBR, Alexey Proskuryakov. Original Message: Hi all. First post to this list. I apologize if this is not a unique question. I''ve been searching for the past hour, but have not found an answer so I thought I''d try here. I have a simple page <html> <head> <script type="text/javascript"> function say_hi() { alert(''Hi.''); } </script> </head> <body> <input type="button" value="Say Hi" onclick="say_hi();"> </body> </html> When the button is highlighted, IE 6 and FireFox 2.0.0.11 (Windows and Mac) both fire the onclick event when the Enter/Return key is pressed. Safari 3 (neither Windows or Mac) doesn''t. Is there some special way of getting that to work in Safari without resorting to trapping the key in an onkeypress event? Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hmmm, well here is my exact code. See anything? <div id="element-controls"> <%= button_to_function "Add an Element", remote_function(:url => {:action => ''insert_element_controls''}) %> </div> On Dec 9, 7:32 pm, Phillip Koebbe <phillipkoe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hm.. I just did a quick test and when I tabbed to the button and > pressed return, it submitted the form. Maybe you have something else > amiss? > > Safari 3.0.4 (523.12) on Mac OS X 10.4.11 and Windows XP SP2. > > Peace, > Phillip > > On Dec 9, 2007, at 9:11 PM, Pat wrote: > > > > > Has anyone else noticed that buttons rendered with button_to_function > > in Safari don''t work when you hit return? Works find in firefox. Is > > there a know work around?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In addition to my second message, I also found this link on the WebKit Bugzilla: http://bugs.webkit.org/show_bug.cgi?id=14382 It''s not the same test case, but the bug is the same. However, part way down the comments, a person named Dave Hyatt states ========== begin comment ==========There is no bug on Mac. This is really a Windows port issue. On the Mac, spacebar activates a button, and Enter activates the default button in dialogs. The two are distinct. This is expected behavior to a Mac user. On Windows this is not the case (Enter always activates the focused button, and only activates the default button if another button is not focused). ========== end comment ========== Since I''m new to the Mac (past 7 months or so), this was new to me. I did test my case again using the space bar and it worked fine. Go figure. Peace, Phillip On Dec 9, 2007, at 9:49 PM, Pat wrote:> > hmmm, well here is my exact code. See anything? > > <div id="element-controls"> > <%= button_to_function "Add an Element", remote_function(:url => > {:action => ''insert_element_controls''}) %> > </div> > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---