Just a couple ideas, but make sure you have included:
var $components = array('RequestHandler');
in your controller.
Also, you might try including this line in your routes.php file
Router::parseExtensions();
The easy way to trigger the RequestHandler is to append the supported
filetype extension. For example, add '?request.json' to the end of your URL
and the RequestHandler will handle as json. You'll want a subdir in the
/views/layouts directory called json so it will be /views/layouts/json and
in that dir you can have a layout file with the same name as the regular one
but contents like this:
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
header('Content-Type: text/x-json');
echo $content_for_layout;
Although RequestHandler may take care of the headers for you.
The best way to figure this stuff out is to view the RequestHandler
component source.
In our case I just created an override in the app_controller for the
function 'render' that allows you to specify the layout/view on demand in
the url as named params and then calls the standard render function. That
way I could pull different ajax 'views' of the same controller/action based
on the URL requested.
HTH
On Thu, Nov 20, 2008 at 5:38 PM, ulterior <[EMAIL PROTECTED]> wrote:
>
> Hey All,
>
> I'm really drawing a blank here! All my ajax requests are using the
> default layout even though I am setting the layout in the controller
> action.
>
> $this->layout = 'ajax';
>
> I've also used the beforeFilter method to set it:
>
> if ($this->RequestHandler->isAjax() == true){
> $this->layout = 'ajax';
> }
>
> I read in the manual that RequestHandler should set the ajax layout
> for you but it doesn't.
>
> I've searched for 'layout' through my entire project, weeded through
> the results all to no avail!
>
> Has anyone else had this problem? Any ideas on steps to troubleshoot
> it?
>
> Any help is greatly appreciated!
>
> -Chris
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---