Update a div

I have this list of users that I want to include in a group. I choose
these users from a larger group - all the employees for a company , for
example. I have both lists displayed on the page, the thing is that when
I choose a user to include in my list I want to have that user shown in
the list (update that list) but also have that user taken out of the
other list. So basically I need to update two divs. I am using a
form_remote_tag to :update the one div, but how do I update the second.
Is there a way to update two divs as a result of an action? thanks,

-S

Shandy N. wrote:

Is there a way to update two divs as a result of an action? thanks,

RJS templates is one:

page.insert_html :bottom, ‘thoughts’, :partial => ‘thought’
page.visual_effect :highlight, ‘thoughts’
page.form.reset ‘thought-form’

This tutorial is long-winded but it’ll give you the basics:
http://ajax.stealthsettings.com/rjs-templates-for-rails/rjs-templates-for-rails-what-is-rjs/

Then check out the docs:
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html

Shandy N. wrote:

I have this list of users that I want to include in a group. I choose
these users from a larger group - all the employees for a company , for
example. I have both lists displayed on the page, the thing is that when
I choose a user to include in my list I want to have that user shown in
the list (update that list) but also have that user taken out of the
other list. So basically I need to update two divs. I am using a
form_remote_tag to :update the one div, but how do I update the second.
Is there a way to update two divs as a result of an action? thanks,

-S

Hi
You can update two divs using :update =>“div1,div2” in form_remote_tag
and also by using
render :update do |page|
page.replace_html ‘div1’, :partial => ‘file1’
page.replace_html ‘div2’, :partial => ‘file2’

in the controller

Abhi M. wrote:

Shandy N. wrote:

I have this list of users that I want to include in a group. I choose
these users from a larger group - all the employees for a company , for
example. I have both lists displayed on the page, the thing is that when
I choose a user to include in my list I want to have that user shown in
the list (update that list) but also have that user taken out of the
other list. So basically I need to update two divs. I am using a
form_remote_tag to :update the one div, but how do I update the second.
Is there a way to update two divs as a result of an action? thanks,

-S

Hi
You can update two divs using :update =>“div1,div2” in form_remote_tag
and also by using
render :update do |page|
page.replace_html ‘div1’, :partial => ‘file1’
page.replace_html ‘div2’, :partial => ‘file2’

in the controller

This doesn’t work at all, at least not for me. I have a form_remote_tag
with :update => ‘div1, div2’ and then in my controller I have the above
code. If I leave off the :update, my button for the form act as if they
haven’t been hit and with the update I get the same behavior. Is there
something that I’m missing? Thanks,

-S

Shandy N. wrote:

This doesn’t work at all, at least not for me. I have a form_remote_tag
with :update => ‘div1, div2’ and then in my controller I have the above
code. If I leave off the :update, my button for the form act as if they
haven’t been hit and with the update I get the same behavior. Is there
something that I’m missing? Thanks,

-S

I take that back, it is working - kinda, but I think my issue is in my
code seperate then from your code Abhi. I removed the :update in the
form tags and that seemed to help a lot. Thanks,

-S

Shandy N. wrote:
I removed the :update in the

form tags and that seemed to help a lot. Thanks,

Correct. When you use RJS templates you should not specify the :update
argument in your Ajax calls.