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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
  • html xmlns="http://www.w3.org/1999/xhtml">

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.

查看全部
weixin_33695450
weixin_33695450
2011/12/15 20:24
  • layout
  • controller
  • ajax
  • 点赞
  • 收藏
  • 回答
    私信

1个回复