Clear a form after an ajax create

I’m just starting to play with rjs, I have an index page with a
remote_form_for to create new items. That’s working. However, after
the ajax updates my container, the input form needs to be cleared.
I’m not sure how to do that

http://pastie.caboo.se/75318

tia

linoj

I’m just starting to play with rjs, I have an index page with a
remote_form_for to create new items. That’s working. However, after
the ajax updates my container, the input form needs to be cleared.
I’m not sure how to do that

Can you show the partial _form …?

There is an error when you use @empty in this line:

page.replace_html ‘create_form’, {:partial=>‘form’, :object=> @empty}

the @empty object is a Choice model and you are using it in your _form
partial like a Form object… ‘text_field’ is not defined in a Choice
object.

thank you, yes, I realize the empty Choice object is not correct, that
is my question. I’m looking for suggestion how to clear the form
fields from the rjs.

The _form.html.erb is quite simple

Prompt
<%= form.text_field :prompt %>

On Jul 2, 4:28 am, Moises D. [email protected]

I’m looking for suggestion how to clear the form fields from the rjs.

The _form.html.erb is quite simple

Prompt
<%= form.text_field :prompt %>

Ok, you can do this using rjs… first mark the form with an html id
(‘my_form’). After, you can use in the rjs template something like this:

page[‘my_form’].reset()

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs