"conditional" layout according to XHR or not

Hi. This is what I mean:
Let’s consider a ‘show’ action called by URLs of the form: “GET /posts/
42”
In this project, this action can be either called directly or within a
page with XHR (ajax). Is there a pretty way to render the page within
the layout when it’s a direct call, and without it when it’s an XHR
call?

Thank you…

On 7/9/07, Aurélien Malisart [email protected] wrote:

class FooController
layout :select_layout

private
def select_layout
return nil if request.xhr?
“my_layout”
end
end

Though if you’re getting an xhr request shouldn’t you be returning
javascript anyway? There’d be no layout for that.

Pat

Thanks!

Though if you’re getting an xhr request shouldn’t you be returning
javascript anyway? There’d be no layout for that.

In that case, i’m returning the rendering of a partial (a form).