I''m using a form_remote_tag to create an ajax form, but would like to clear the values in the fields after submitting the form. Is there a way to do this that I am missing or am I going to have to write my own javascript to do it? -- Sterling Anderson sterling [at] sterlinganderson.net http://sterlinganderson.net/ 608.239.8387 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sterling, The simplest approach I''ve found is to redraw the form. I''m assuming you''ve got some kind of rjs file to facilitate returning error messages, etc. Make sure the form is inside a div tag that has a unique id and then if the form is submitted succesfully execute a page.replace "unique-id", :partial => ''form_partial'' You could theoretically save yourself a small amount of bandwidth by writing some custom javascript, but the cost of loading that javascript on every page load will likely be close to the load created by refreshing the entire form. (assuming the form isn''t too large) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Try the :loading => "this.reset();" option, or :loaded, :completed, :after etc depending on when exactly you want it cleared. On 05/09/06, Aaron <stocad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Sterling, > > The simplest approach I''ve found is to redraw the form. I''m assuming > you''ve got some kind of rjs file to facilitate returning error > messages, etc. Make sure the form is inside a div tag that has a > unique id and then if the form is submitted succesfully execute a > > page.replace "unique-id", :partial => ''form_partial'' > > You could theoretically save yourself a small amount of bandwidth by > writing some custom javascript, but the cost of loading that javascript > on every page load will likely be close to the load created by > refreshing the entire form. (assuming the form isn''t too large) > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Sterling, Sterling Anderson wrote:\> I''m using a form_remote_tag to create an ajax form, > but would like to clear the values in the fields after > submitting the form.If you''re using Ajax to submit your form (as suggested) you can just use page.form.reset(''name_your_form'') hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What also works with AJAX: :success => "Form.reset(''HTML ID OF FORM'')" --Lars On 9/6/06, Bill Walton <bill.walton-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> > > Hi Sterling, > > Sterling Anderson wrote:\ > > > I''m using a form_remote_tag to create an ajax form, > > but would like to clear the values in the fields after > > submitting the form. > > If you''re using Ajax to submit your form (as suggested) you can just use > page.form.reset(''name_your_form'') > > hth, > Bill > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---