function beforeRender()
{
if ($this->RequestHandler->isAjax())
{
$this->viewPath = $this->viewPath.'/ajax'; // change the view directory
# $this->ext = '.jhtml'; // or change the extension
}
}
So now when an action is called by an ajax script, Cake sees this and changes the view path, and calls the following view app/views/controller/ajax/action.thtml.
Alternatively you can have the extension of your view files changed. So all ajax calls would call views ending in .jhtml for example. Your choice!
So now my ajax views are separated from my normal views.
This site contains the musings of Joel Moss, and is powered by Codaset pages; a simple, yet powerful way to host your static site. Just commit and push your site to your free Git repository at Codaset, and that's it!
Related Articles...
- Goodbye Wordpress, Hello Jekyll
- Quick and easy emailing in Ruby with Pony
- Concerned with Rails
- Codaset Opens up its Beta to Everyone.
- Railings: A full featured Ruby on Rails template
- CSS Pick and Mix Classes
- A sexy, ajax based jQuery dialog window, with a one track mind.
- Codaset is alive!
- 10 Reasons why Ruby is better than PHP - Reason #5
- 10 Reasons why Ruby is better than PHP - Reason #4
