# Rails 3's rails.js should offer Ajax.Updater

**URL:** <https://www.ruby-forum.com/t/rails-3s-rails-js-should-offer-ajax-updater/187903>\
**Category:** Rails\
**Created:** [May 1, 2010, 1:04pm UTC](https://www.ruby-forum.com/t/rails-3s-rails-js-should-offer-ajax-updater/187903 "2010-05-01T13:04:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![funkensturm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e56c9b/32.png) [@funkensturm](https://www.ruby-forum.com/u/funkensturm)\
**Post date:** [May 1, 2010, 1:04pm UTC](https://www.ruby-forum.com/t/rails-3s-rails-js-should-offer-ajax-updater/187903/1 "2010-05-01T13:04:54Z")

</div>

Hey,

I have a form on a website that I would like to be submitted remotely

- to not have to reload the whole page. Only the form should update,  
so that e.g. error messages can be displayed. Makes sense 🙂

However, with the current rails.js javascript in Rails 3, the only way  
to do this is using

form\_for … :remote =\> true

and then render a RJS in the controller, which will do… what? Try to  
puzzle the form values and error messages into the invalid form?

Instead, I came up with this spontaneous extension to rails.js:  
[http://gist.github.com/385167](http://gist.github.com/385167)

With something as easy as

form\_tag … :html =\> { ‘data-update’ =\>  
‘div\_with\_the\_form\_to\_be\_updated’ }

I can now have the controller render HTML to update the form when it  
has errors, and still RJS if I would like to do some fancy stuff in  
case the submission was successful.

I assume this feature should be included in rails.js. It would take  
just a few lines of smart modification.

In the far future, ActionView might even be modified to implement the  
good ol’

form\_tag … :update =\> ‘div\_to\_be\_updated’

I would love to hear your opinion about this.  
All the best!
