Forum: Ruby on Rails How to refresh multiple DIV on a single Ajax Call

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
047c2e2a6349db15db769e3ad46cf936?d=identicon&s=25 Kumar Saurav (sauravsuman012)
on 2009-01-21 16:39
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
C4bfcc81ac9281cb905f38e97e4d4e0b?d=identicon&s=25 Shandy Nantz (snantz)
on 2009-01-21 16:57
Kumar Saurav 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
047c2e2a6349db15db769e3ad46cf936?d=identicon&s=25 Kumar Saurav (sauravsuman012)
on 2009-01-21 17:35
Shandy Nantz wrote:
> Kumar Saurav 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
This topic is locked and can not be replied to.