title: jQuery is not defined (in [Symfony] templating environment)
body: <p>I am trying to display a page that uses jQuery. The AJAX functionality implemented in the page does not work. </p>
  
  <p>I am using FF for debugging. When I look in the console panel, I see the following error: 'jQuery is not defined'. Ah, that's an easy one I think - maybe the jQuery file has not been included correctly, or not found etc. So I take a look at the HTML and click on the node - lo and behold, the <strong>jQuery script has been CORRECTLY</strong> included in the page.</p>
  
  <p>Although none of the other js libraries in the pages where jQuery is referenced uses '$' (like prototype), I have invoked the noConflict() method in the jQuery logic, just in case I use a conflicting library at a later stage.</p>
  
  <p><strong>[Edit]</strong></p>
  
  <p>I think the problem is related to the file that I am using jQuery in a templating environment (Symfony 1.4 to be precise). For those not familiar with the Symfony templating system, essentially, the view model is comprised of a 'layout' file (the template), which then gets decorated (decorator pattern), with other bits of information (lets call this 'page content'). </p>
  
  <p>The final page looks roughly something like this:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
    &lt;script type="text/javascript" src= "http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" &gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
     &lt;!-- page contents go here --&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am loading jQuery into the template (i.e. the 'layout' in Symfony terminology).</p>
  
  <p>The reasoning for this being that the JQ library is cached client side, and is available for the pages that require it. The dynnamic pages (whose content go into the 'page content' section of the layout), will then have their own jQuery logic. This (using the "wrapper function" idea provided in the answer by Mark Schultheiss below), looks like this:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  /*&lt;![CDATA[*/
  jQuery(function()
  {
   jQuery.noConflict();
   jQuery(document).ready(function(){
    jQuery("div.tpaccordion div.accItem").hide();
    jQuery("#latestVideosHolder").show();
    jQuery("div.tpaccordion h3").click(function(){
     jQuery(this).next().slideToggle("slow")
     .siblings("div.accItem:visible").slideUp("slow");
     jQuery(this).toggleClass("active");
     jQuery(this).siblings("h3").removeClass("active");
    });
   });
  });
  /*]]&gt;*/
  &lt;/script&gt;
  </code></pre>
  
  <p>**[Edit2]**Corrected the syntax error. Now I'm back to getting the jQuery is not defined error. :(</p>