# Form reset through rjs

**URL:** <https://www.ruby-forum.com/t/form-reset-through-rjs/109673>\
**Category:** Rails\
**Created:** [July 17, 2007, 7:08pm UTC](https://www.ruby-forum.com/t/form-reset-through-rjs/109673 "2007-07-17T19:08:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 17, 2007, 7:08pm UTC](https://www.ruby-forum.com/t/form-reset-through-rjs/109673/1 "2007-07-17T19:08:49Z")

</div>

I have update.rjs

if @category.errors.length \> 0  
page.replace\_html ‘flash\_box’, error\_messages\_for(:category)  
page.show ‘flash\_box’  
else  
page.hide ‘flash\_box’  
page.replace\_html @category.dom\_id, :partial =\> “category”, :locals =\> {  
:category =\> @category}  
page.visual\_effect :highlight, @category.dom\_id, :startcolor =\>  
“’#fff000’”  
page.replace\_html ‘form\_add\_new’, :partial =\> “index”  
page[“category\_form”].reset  
end

So basicly i am updating a div with edited category(works), then I try  
to replace the form from edit form to add new category form(works) but i  
cannot clear  
this form, it still has values from my edit form even though i am making  
a .reset.

This method works on my create.rjs  
i dont have errors in firebug.

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 19, 2007, 1:15am UTC](https://www.ruby-forum.com/t/form-reset-through-rjs/109673/2 "2007-07-19T01:15:54Z")

</div>

Pawel

> page[“category\_form”].reset

You may try something like :

page[‘new\_category’].down(‘form’).reset

HTH

## Alain R.

[http://blog.ravet.com](http://blog.ravet.com)
