Cakephp $ layout不会改变

So here is the situation: I have my default.ctp and my ajax.ctp where my ajax.ctp is just the blank $content_for_layout;

When i'm doing an autocomplete ajax call I must change the layout to 'ajax' obviously. So I have this function in my controller

function beforeFilter() {
        if($this->RequestHandler->isAjax()) {
            $this->layout = 'ajax';

However when i look at the results of my autocomplete I get this in my options:

  • DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
  • html xmlns="">

Which basicly is my default layout. So my guess is that the layout didn't change

Anyone else encountered this problem? Did I forget to add something in my controller ? All the helpers and components are in place.

2011/12/15 20:24
  • layout
  • controller
  • ajax
  • 点赞
  • 收藏
  • 回答