I have a form that includes some filtering criteria (select customers based on age, sex, status, etc). I want to add a ''calculate'' button on the form which will go off and calculate, then display, how many customers will be included in the selection. I want the user to be able to amend the filtering until they are happy with the numbers, without having to submit the form and go back if the numbers are not right. If there was only one filter (ie one field value), I would user an observer and in the controller use request.raw_post to get the single value to apply to the query. However as there are several form fields required, I cannot see how I can access them without first submitting the form. -- 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 -~----------~----~----~----~------~----~------~--~---
Kevin Hankinson wrote:> I have a form that includes some filtering criteria (select customers > based on age, sex, status, etc). I want to add a ''calculate'' button on > the form which will go off and calculate, then display, how many > customers will be included in the selection. I want the user to be able > to amend the filtering until they are happy with the numbers, without > having to submit the form and go back if the numbers are not right. >If you can accept a link instead of the button, then: link_to_remote ''calculate'', :url=>{:action=>''calculate''},:with => "Form.serialize(''your_form_id'')" Regards Massimo http://www.addsw.it -- 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 -~----------~----~----~----~------~----~------~--~---
Massimo wrote:> Kevin Hankinson wrote: >> I have a form that includes some filtering criteria (select customers >> based on age, sex, status, etc). I want to add a ''calculate'' button on >> the form which will go off and calculate, then display, how many >> customers will be included in the selection. I want the user to be able >> to amend the filtering until they are happy with the numbers, without >> having to submit the form and go back if the numbers are not right. >> > > If you can accept a link instead of the button, then: > > link_to_remote ''calculate'', :url=>{:action=>''calculate''},:with => > "Form.serialize(''your_form_id'')" > > Regards > Massimo > http://www.addsw.itthanks for this. Ideally i want to use a form observer: <%= observe_field(:groups, :frequency=> 0.5, :update=> :totalCustomers, :url=>{:action=>:total_in_group}, :with=>"Form.serialize(''newAdvert'')", :loading=>"Element.show(''progress1'')", :complete=>"Element.hide(''progress1'')") %> However, I get a javascript error: Error: Expected } ''newAdvert'' is the name of my form It goes away if i remove the :with parameter. Can anyone spot the mistake? -- 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 -~----------~----~----~----~------~----~------~--~---
> thanks for this. Ideally i want to use a form observer: > > > <%= observe_field(:groups, :frequency=> 0.5, :update=> :totalCustomers, > :url=>{:action=>:total_in_group}, :with=>"Form.serialize(''newAdvert'')", > :loading=>"Element.show(''progress1'')", > :complete=>"Element.hide(''progress1'')") %>With observe_field, I think you need :with=>"form=Form.serialize(''newAdvert'')"> > ''newAdvert'' is the name of my formnewAdvert must be the form ID (form name is not important). Check your html source. -- 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 -~----------~----~----~----~------~----~------~--~---
Massimo wrote:> >> thanks for this. Ideally i want to use a form observer: >> >> >> <%= observe_field(:groups, :frequency=> 0.5, :update=> :totalCustomers, >> :url=>{:action=>:total_in_group}, :with=>"Form.serialize(''newAdvert'')", >> :loading=>"Element.show(''progress1'')", >> :complete=>"Element.hide(''progress1'')") %> > > > With observe_field, I think you need > :with=>"form=Form.serialize(''newAdvert'')" >> >> ''newAdvert'' is the name of my form > > newAdvert must be the form ID (form name is not important). Check your > html source.thanks for pointing this out. Unfortunately, still getting the js error. Expected ''}'' Taking the single qoutes off the form id (''newAdvert'') resolves the js error, but obviously breaks the form serialising when we get to the controller -- 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 -~----------~----~----~----~------~----~------~--~---