Topic: Form Reset

It seems like the tried and true page['form_id'].reset function no longer works.

What is the best way to reset my form after applying some AJAX?

I checked out this thread but none of the proposed solutions are working.


Re: Form Reset

page[].reset should still be the best way..
gues it's part of your ajax return?
  if yes: what does the ajax call return?
  if no:  try $('form_id').reset(); directly

if you got an url i would check it out...

Re: Form Reset

I'm still in dev mode on this no URL

The good news is that It works fine with the inline JS like so

:success => "$('rlinkform').reset();"

I wish the RJS reset wasnt pooping out on me, but whatever.. at least this works!

Thanks ehdoranil, and welcome to Rails forum smile

Re: Form Reset

thanks for the welcome.

if the application works - great smile
however it would intrigue me what ajax now does return. the code should be pretty much the same, so i wonder where rjs got trouble...


Re: Form Reset

I'm not sure why, but now its working with RJS.,,same syntax and all. Go figure

The only thing I would probably want to refactor at this point would be the callbacks.

Right now my form is littered with

:loading => "'ajax_progress')", :complete => "Element.hide('ajax_progress')", :success => "'flash_notice');"

Can this stuff go into RJS as well?

Re: Form Reset

You could make a few helper methods if you have the same thing over and over.  You could put this in your application helper and use it in multiple views.

 def show_ajax_progress

def hide_ajax_progress

def show_flash_notice

:loading => show_ajax_progress, :complete => hide_ajax_progress, :success => show_flash_notice

Re: Form Reset

Thats a great idea Eric