How to refresh multiple DIV on a single Ajax Call


#1

Hi all ,

I have to refresh three div in a single ajax call …
Anybody having any Idea . Please let me help , It would be great for me.

Thanks In Advance


#2

Kumar S. wrote:

Hi all ,

I have to refresh three div in a single ajax call …
Anybody having any Idea . Please let me help , It would be great for me.

Thanks In Advance

I use render :update in my action. For example, if I have a drop down of
stuff and I want to add to a list when I select something from that drop
down but at the say time remove from the drop down what I just selected
I would say something like:

render :update do |x|
page.replace_html ‘stuff_to_select’, :partial => ‘partial_1’
page.replace_html 'list_of_stuff, :partial => ‘partial_2’
page.replace_html ‘message’, :inline => ‘Stuff updated’
end

Assuming that you have the divs names correctly this would update two
partials and display a message in another. I usually use these in
conjunction with link_to_remote or remote_form_tag. If you are using
these helpers, don’t include the :update option in your helper as you
will get strange output displayed in your divs. Hope this helps,

-S


#3

Shandy N. wrote:

Kumar S. wrote:

Hi all ,

I use render :update in my action. For example, if I have a drop down of
stuff and I want to add to a list when I select something from that drop
down but at the say time remove from the drop down what I just selected
I would say something like:

render :update do |x|
page.replace_html ‘stuff_to_select’, :partial => ‘partial_1’
page.replace_html 'list_of_stuff, :partial => ‘partial_2’
page.replace_html ‘message’, :inline => ‘Stuff updated’
end

Hi thanks for help but i am using form_remote_tag on my page and
updating the div there . The code is
<%= form_remote_tag({:url=>{:controller=>‘image_builders’,
:action =>‘image_creation’}, :update =>‘photo’,
:html=>{:onsubmit=>‘UrlGeneration(this)’}})%>

And I have to update the Div(sample1,sample2,sample4) here like photo i
updating .
Do you have any suggestion, if yes please let me know.

Thanks In Advance