Forum: Ruby on Rails Ajax: Multiple Element Update

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dylan S. (Guest)
on 2006-01-12 20:56
(Received via mailing list)
I'm trying to apply an Effect.Highlight only to elements of a Form that
So if a user updated 2 fields of a 10 field form, the Effect.Highlight
be applied to the 2 fields... showing the user what was updated.

My first attempt was to use the :complete=>"eval(request.responseText)"
however, the template that get's rendered won't know what elements to
the Effect too.
My second attempt was to use a Javascript call, like the following...
don't know the correct syntax to use to pull the elements modified from

<% content_for("page_scripts") do -%>
function field_edited() {
  var field =  $('field');              // how do i figure out what was
edited from the Form params ?
  new Effect.Highlight(field);

Any insight into this would be great, as I've been stumbling over this
quite some time now.
Thanks !
De R. (Guest)
on 2006-01-12 21:04
I think this is a doubly loaded question. Not clear how/when you'll show
the highlighted elements. But here is my take on it.

1) Try to deal with the form diff in the ajax call. You know what the
form was and  now what the form is. So you can diff out the user changes
and return the form attributes that have changed.

2) Use an rjs template on the way back and highlight the updated fields
based on you diff.

Hope this helps...
Dylan S. (Guest)
on 2006-01-12 22:12
(Received via mailing list)
Thanks derailed...

1)  You mean within the action called by Ajax (ie:  a form_remote_tag) ?
On updates for example, I'm just doing an "update_attributes" on the
model... but I could diff out what has changed and what hasn't... then
that hash back to the view.  At this point however, I'm not too sure how
tie in the JS... and, in the whole scheme of things, effect the exact
elements that relate to these form fields (ie:  div's surrounding each
field ).

2)  This requires edge, or a plugin, correct ?

Thanks !
De R. (Guest)
on 2006-01-13 04:57

    Take a look at the rjs plugin. You don't need to run to the edge...
    You can find all the info you need here:

Good luck !!
Dylan S. (Guest)
on 2006-01-16 07:10
(Received via mailing list)
>From a controller action, after a form submit, is there a way to pass some
data to the template (or RJS template if you're using them) that is
going to
be rendered ?

For example, passing the template some information as to what elements
Dylan S. (Guest)
on 2006-01-16 20:26
(Received via mailing list)
If anybody was interested, I found this post which pretty much solves my
problem.  Not sure if this is the best approach... but it works !
This topic is locked and can not be replied to.