CakePHP AJAX Layout

后端 未结 5 1054
清歌不尽
清歌不尽 2021-01-15 14:05

I\'m working with a CakePHP application and jQuery Mobile. In the CakePHP application, RequestHandler is turned on, now, jQuery Mobile makes all of it\'s requests as ajax re

5条回答
  •  北海茫月
    2021-01-15 14:36

    The best sollution I think is to configure the request handler in before filter after the mobile browser was detected in your app controller:

    public function beforeRender() {
      if($this->RequestHandler->isMobile()) {
          $this->theme = 'Mobile';//set your theme
          $this->RequestHandler->ajaxLayout = 'public';//this does the trick, set your mobile layout, $this->layout is simply ignored or overwritten by the component
      }
    }
    

提交回复
热议问题