I have a form submitted using remote_form_tag. I have two image buttons in this form. In other languages, I have been able to detect which button was clicked by checking for a GET or POST parameter of the button name with a .x after it (such as buttonName.x = 13) In the params I am getting from my form in Rails, I get hash entries for all button names with no .x or .y extensions and no other indicator as to which button was clicked. The output of essentially doing debug(params) simply shows btnSearch: "" btnClear: "" What is Rails'' solution to this? It seems to be eliminating rather useful (and commonly used) info. -- gw --~--~---------~--~----~------------~-------~--~----~ 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 21 Apr 2008, at 19:29, Greg Willits wrote:> > I have a form submitted using remote_form_tag. I have two image > buttons in this form. > > In other languages, I have been able to detect which button was > clicked by checking for a GET or POST parameter of the button name > with a .x after it (such as buttonName.x = 13) > > In the params I am getting from my form in Rails, I get hash entries > for all button names with no .x or .y extensions and no other > indicator as to which button was clicked. > > The output of essentially doing debug(params) simply shows > btnSearch: "" > btnClear: ""I was surprised by this so I gave it a go. It worked as you would expect with a regular form, but not with the form_remote_tag. The big difference is of course that in the second case the form is serialized by prototype rather than the browser, and prototype obviously doesn''t know how to get the click location. Whether this is an omission or a genuinely hard thing to do I don''t know.>Fred> > What is Rails'' solution to this? It seems to be eliminating rather > useful (and commonly used) info. > > -- gw > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Apr 21, 2008, at 11:40 AM, Frederick Cheung wrote:> On 21 Apr 2008, at 19:29, Greg Willits wrote: > >> I have a form submitted using remote_form_tag. I have two image >> buttons in this form. >> >> In the params I am getting from my form in Rails, I get hash entries >> for all button names with no .x or .y extensions and no other >> indicator as to which button was clicked. >> >> The output of essentially doing debug(params) simply shows >> btnSearch: "" >> btnClear: "" > > I was surprised by this so I gave it a go. It worked as you would > expect with a regular form, but not with the form_remote_tag. The big > difference is of course that in the second case the form is serialized > by prototype rather than the browser, and prototype obviously doesn''t > know how to get the click location. Whether this is an omission or a > genuinely hard thing to do I don''t know.OK, well, at least I know it''s not me. And maybe it explains another problem I am having with the same form which I don''t seem to have with a non-Ajax form. Hrmmm. So much for Ajaxifying this app (UI depends heavily on differentiating image buttons). Thanks for the verification. -- gw --~--~---------~--~----~------------~-------~--~----~ 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 21 Apr 2008, at 20:23, Greg Willits wrote:> > On Apr 21, 2008, at 11:40 AM, Frederick Cheung wrote: >> On 21 Apr 2008, at 19:29, Greg Willits wrote: >> >>> I have a form submitted using remote_form_tag. I have two image >>> buttons in this form. >>> >>> In the params I am getting from my form in Rails, I get hash entries >>> for all button names with no .x or .y extensions and no other >>> indicator as to which button was clicked. >>> >>> The output of essentially doing debug(params) simply shows >>> btnSearch: "" >>> btnClear: "" >> >> I was surprised by this so I gave it a go. It worked as you would >> expect with a regular form, but not with the form_remote_tag. The big >> difference is of course that in the second case the form is >> serialized >> by prototype rather than the browser, and prototype obviously doesn''t >> know how to get the click location. Whether this is an omission or a >> genuinely hard thing to do I don''t know. > > > OK, well, at least I know it''s not me. And maybe it explains another > problem I am having with the same form which I don''t seem to have > with a non-Ajax form. > > Hrmmm. So much for Ajaxifying this app (UI depends heavily on > differentiating image buttons). > > Thanks for the verification. >I hacked together a quick experiment: add an onclick to the form that does <script> function clicker(form, event){ offsets = event.element().cumulativeOffset(); x = event.pointerX() - offsets[0] y = event.pointerY() - offsets[1] params = Object.extend(Form.serialize(form, {hash: true}), {x: x, y: y}) new Ajax.Updater(''to_update'', ''/dummy'', {asynchronous:true, evalScripts:true, parameters:params, method: ''get''}); return false; } </script> <% form_tag({},{:onclick => ''clicker(this, event); return false''}) do %> .. Seems to be a start. (of course you''d have to add stuff to check that the click was on an image element and should trigger a submit etc... Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---