Link_to_remote > in :action , interrupt ajax to render a new

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

Thanks :slight_smile:
I hope that RJS will be part of the next release of rails. More easy
than plugin.

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