title: Sitecore Page Editor Javascript Error
body: <p>In the sitecore project I'm currently working on, we've noticed that our Page Editor is not behaving like a Vanilla install's Page Editor. For every placeholder we must click twice to get the editor to focus on that placeholder. On the first click, the tool-bar pop-up focus changes to point at the placeholder or sublayout that we just clicked on but only highlights that item on the second click.</p>
  
  <p>I believe this bahavior is due to a JS error we're getting. The error is:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'sc-renderMoreSection' of undefined 
  renderTemplate 
  Sitecore.PageModes.ChromeControls.Base.extend.renderMoreSection
  Sitecore.PageModes.ChromeControls.Base.extend.updateCommands
  Sitecore.PageModes.ChromeControls.Base.extend.show
  Sitecore.PageModes.SelectionFrame.Sitecore.PageModes.ChromeFrame.extend.showSides
  value
  Sitecore.PageModes.ChromeFrame.Base.extend.show
  Sitecore.PageModes.SelectionFrame.Sitecore.PageModes.ChromeFrame.extend.show     
  value 
  select
  Sitecore.PageModes.Chrome.Base.extend._clickHandler
  c jquery.noconflict.js:16
  d.event.handle jquery.noconflict.js:16
  k.handle.m
  </code></pre>
  
  <p>The JS is located in a generated script that seems to be pretty standard across Sitecore installations. The method where this error is occuring is</p>
  
  <pre><code>this.renderTemplate = function(templateName, template, data, options) {
     if (!$sc.template[templateName]) {
        $sc.template(templateName, template);
     }
    return $sc.tmpl(templateName, data, options);
  };
  </code></pre>
  
  <p>in the <code>!$sc.template[templateName]</code> statement because template is undefined.</p>
  
  <p>Has anyone run into anything similar before? Anyone have any idea what might cause this issue? </p>
  
  <p>We are running Sitecore 6.5 and jQuery 1.7.2</p>
  
  <p>EDIT: After a day of troubleshooting this issue, I've discovered the following:</p>
  
  <p>Sitecore's page editor is overwriting our version of jQuery, 1.7.1, which we run in no-conflict mode with its own version, 1.5.1, which it runs in no-conflict mode. Our scripts no-conflict to a $$$ alias and sitecore no-conflicts to $sc. At the end of it all, our $ is jquery 1.5.1 (which puzzles me, as it should be returned to the standard $ if I understand no-conflict correctly).</p>
  
  <p>This shouldn't matter as far as the page editor is concerned. The page I'm testing my tweaks on doesn't use jQuery dependent on 1.7. The issue is related to the "Template" jquery plugin that the sitecore page editor script includes. For reasons I have not be able to identify, this module is not working in the page editor and is the source of the error. Our other Sitecore sites still function using the one this site is including. Removing the template plugin causes other sites to behave the way our site currently is. </p>
  
  <p>Also, Sitecore includes prototype in this script as well, but not mapped to $</p>