title: How to enable ZendX integrated Jquery in Layouts
body: <p>I am trying to understand why ZendX_JQuery will not work when used directly in a layout. It works perfectly fine when in a view:</p>
  
  <ul>
  <li>creates the needed code</li>
  <li>puts the JQuery script in the <em>head</em> tag</li>
  </ul>
  
  <p>But when used inside the layout</p>
  
  <ul>
  <li>creates the needed code</li>
  <li>does <strong>not</strong> insert the JQuery script in the <em>head</em> tag</li>
  </ul>
  
  <p>Can this be overcome, and how? And, if anyone can answer this, why is it doing this?</p>
  
  <p>To make it perfectly clear, here is what i want to do:</p>
  
  <pre><code>    //layout.phtml file
      &lt;head&gt;
      &lt;?php echo $this-&gt;jQuery();?&gt;
      &lt;/head&gt;
      &lt;body&gt;
  &lt;?php echo $this-&gt;ajaxLink("Like",
  
                      "/mod/instr/like/id/".$this-&gt;books['id'],
  
                      array('update' =&gt; '#ajaxed',
                      'beforeSend'=&gt;'fadeout'
                      ));
  ?&gt;
  &lt;?php echo $this-&gt;layout()-&gt;content; ?&gt;
      &lt;/body
  </code></pre>
  
  <p>It means, that I wish to put a jQuery object inside a layout. I want to put some jQuery related code <strong><em>DIRECTLY</em></strong> inside my layout file, not just the part that allows jQuery to initialized for the views that require it.</p>
  
  <p><strong><em>Edit:</em></strong>
  Ok, so here's the init function in the Bootstrap</p>
  
  <pre><code>    protected function _initJqueryLoad()
      {
  
          $view = new Zend_View();
       // $view-&gt;addHelperPath('ZendX/JQuery/View/Helper/', 'ZendX_JQuery_View_Helper');
  $view-&gt;addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
      $view-&gt;jQuery()-&gt;addStylesheet('/js/jquery/css/ui-lightness/jquery-ui-1.7.2.custom.css')
          -&gt;setLocalPath('/js/jquery/jquery.js')
          -&gt;setUiLocalPath('/js/jquery/js/jquery-ui-1.7.2.custom.min.js');
  ZendX_JQuery::enableView($view);
      }
  </code></pre>
  
  <p>My layout file contains this in the head:</p>
  
  <pre><code>    &lt;?php echo $this-&gt;headLink()-&gt;prependStylesheet($this-&gt;baseUrl().'/css/admin.css'); ?&gt;
      &lt;?php echo $this-&gt;headLink()-&gt;prependStylesheet($this-&gt;baseUrl().'/css/form.css'); ?&gt;
  &lt;?php 
  echo $this-&gt;headScript()-&gt;prependFile('/js/JP.js','text/javascript','');?&gt;
  &lt;?php echo  $this-&gt;jQuery(); ?&gt;
  &lt;/head&gt;
  </code></pre>
  
  <p>So the JQuery should be enabled in every view that uses this layout.
  The code that runs in my views, but not in my layouts is:</p>
  
  <pre><code>&lt;div id="ajaxed"&gt;
  &lt;? 
  echo $this-&gt;ajaxLink("Like",
  
                      "/mod/instr/like/id/".$this-&gt;books['id'],
  
                      array('update' =&gt; '#ajaxed',
                      'beforeSend'=&gt;'fadeout'
                      ));
                       echo $this-&gt;ajaxLink("Don't like",
  
                      "/mod/instr/hate/id/".$this-&gt;books['id'],
  
                      array('update' =&gt; '#ajaxed'));?&gt;
  
  
  &lt;/div&gt;
  </code></pre>