RJS and after_filter

Hello all,

I need to call page.replace_html in every Ajax call.
Is there a way to do this in some after_filter ?

I tried a render :update do |page| in after_filter, but it says that
can only render once per action…

Thanks in advance…

Parra

On 2/12/07, Marcello P. [email protected] wrote:

Hello all,

I need to call page.replace_html in every Ajax call.
Is there a way to do this in some after_filter ?

I tried a render :update do |page| in after_filter, but it says that
can only render once per action…

I haven’t tried it but I bet you can do:

def my_after_filter
response.body << update_page do |page|
page[‘element-id’].replace render :partial => “blah”
end
end

Chad

Marcello P. wrote:

I need to call page.replace_html in every Ajax call.
Is there a way to do this in some after_filter ?

Given render :update do |page|, page is just a variable. You can pass
it into a shared function, and that can then do both specific and
generic stuff to it, following typical OO design techniques.


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

Marcello P. wrote:

But that gives an undefined method `update_page’ error…
I could not find the problem…

<%= render :update => |page| do
end
%>

right?


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

Thanks Chad,

But that gives an undefined method `update_page’ error…
I could not find the problem…

Parra

If you’re calling it from inside a controller, update_page should
work. Are you sure you’re defining it in a controller as an instance
method?

Chad

On 2/12/07, Phlip [email protected] wrote:

right?

No, that’s not right. Inside a view, you use update_page, not render
:update. Internally render :update simply delegates to update_page.

Chad

Yes…
But I need to call it in after_filter in a Controller…
I doing something wrong…

Chad and all…

This is what I’m doing:

class TestController < ApplicationController
after_filter :setbla

def setbla
response.body << update_page do |page|
page[‘element_id’].replace render :partial => “blah”
end
end

def index
end
end

I get the error:
undefined method `update_page’ for #TestController:0x347e408

Where is the mistake ???
Or is there another way to do that ??

Thanks

Have you found a solution? i’m also struggling with that issue