Forum: Ruby on Rails link_to_remote > in :action , interrupt ajax to render a new

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.
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-26 20:04
(Received via mailing list)
Hello,

I have a simple link_to_remote that refresh a div. I just want to know
if it's possible to interrupt the div's refresh inside :action to
perform a complete reload of the page, outside of the div

Actually, I havea a new page, but loaded inside the ":update" div.

Someone have an idea please ?


the rhtml:
****

link_to_remote "yeah" , :update => "div" , :url => { :action =>
"theaction" }

the rb:
****

def theaction
    count -= 1
    if count > 0
       redirect_to :action "main" # to refresh all the page
    else
       render :partial => "..." # refresh inside div stuff
    end
end
337cdd270761e0e6f4356de45b04d388?d=identicon&s=25 Jonathan Viney (jonny)
on 2006-01-26 23:42
I don't think you can do it from insode the action like in the example
you gave, but you can do it with RJS (you need to be yusing edge rails.

View:

<%= link_to_remote 'yeah', :url => { :action => :theaction } %>

Controller:

def theaction
  # update count here, you'll probably need to use the session
end

theaction.rjs:

if @session[:count] > 0
  page.redirect_to :action => :main
else
  page.replace_html 'div', :partial => "..."
end

Cheers, -Jonny.


oo00oo wrote:
> Hello,
>
> I have a simple link_to_remote that refresh a div. I just want to know
> if it's possible to interrupt the div's refresh inside :action to
> perform a complete reload of the page, outside of the div
>
> Actually, I havea a new page, but loaded inside the ":update" div.
>
> Someone have an idea please ?
>
>
> the rhtml:
> ****
>
> link_to_remote "yeah" , :update => "div" , :url => { :action =>
> "theaction" }
>
> the rb:
> ****
>
> def theaction
>     count -= 1
>     if count > 0
>        redirect_to :action "main" # to refresh all the page
>     else
>        render :partial => "..." # refresh inside div stuff
>     end
> end
19403f509ca90e8ffe072214c6cba896?d=identicon&s=25 oo00oo (Guest)
on 2006-01-27 09:03
(Received via mailing list)
Thanks :)
I hope that RJS will be part of the next release of rails. More easy
than plugin.
This topic is locked and can not be replied to.