title: CakePHP 2.0: How to switch to js layout?
body: <p>I would like an action in one of my controllers to output plain javascript, but I can't find anything in the Book on the proper way to achieve this.</p>
  
  <p>I've tried <code>$this-&gt;response-&gt;type('js');</code> which does set the <code>Content-Type: text/javascript; charset=UTF-8</code> but doesn't change the layout to Layouts/js/default.ctp</p>
  
  <p>I keep finding posts all over saying to use <code>$this-&gt;RequestHandler-&gt;renderAs($this, 'js')</code>
  but it's as if that method no longer exists: <a href="https://groups.google.com/forum/?fromgroups=#!topic/cake-php/wZu0NGguQxg" rel="nofollow">What's the usage of app\views\layouts\js?</a></p>
  
  <p>The only thing that has worked so far is <code>$this-&gt;layoutPath = "js";</code> according to: <a href="http://www.balistupa.com/blog/2009/07/how-to-change-cakephp-layout/" rel="nofollow">How to change cakephp layout?</a></p>
  
  <p>However, this article seems to be from Cake 1.3 days. Is this still the correct way to do switch to the js layout?</p>