开发者

CakePHP 2.0 not using my Ajax layout

开发者 https://www.devze.com 2023-03-25 14:05 出处:网络
I am in progress of migrating an app from CakePHP 1.3 to 2.0, and have noticed a pr开发者_高级运维oblem with the ajax parts of my app, in that CakePHP is serving up Ajax responses with the default.ctp

I am in progress of migrating an app from CakePHP 1.3 to 2.0, and have noticed a pr开发者_高级运维oblem with the ajax parts of my app, in that CakePHP is serving up Ajax responses with the default.ctp layout, and not my ajax.ctp.

Is there anything I need to do in particular to get the ajax layout to work? It's currently located in View/Layouts/ajax.ctp with my default.ctp which works fine.


Did you specify the layout in beforeRender in your controller or app_controller? If so, an easy hack would be $this->autoLayout = false;; or better: call $this->render('view_name','ajax'); at the end of your action.

You probably use RequestHandler (I heard it will automatically use ajax layout for ajax requests, but I rarely use it, so I don't know).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号