title: Why can't I get datepicker to work with this TypeError: o is undefined error?
body: <p>I have the following code at the bottom of my page (right before I close the body tag)</p>
  
  <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"&gt;&lt;/script&gt;
  &lt;script src="/js/main.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I double-checked through my "view source" to make sure the links aren't broken and everything is there as it should be.</p>
  
  <p>In my <code>main.js</code> file I have the following:</p>
  
  <pre><code>$(document).ready(function(){
      imp_init_fields();
  });
  
  function imp_init_fields() {
      if( $('.datepicker')[0] ) {
          $('.datepicker').datepicker();
      }
  }
  </code></pre>
  
  <p>As you can see, nothing particularly crazy, just setting up a datepicker as I have done it a million times.</p>
  
  <p>Now, when I go on the page in question and I click on my text input the calendar popup appears. However, as soon as I try to interact with the calendar (change month, pick a date, or anything) nothing happens and I get the following error:</p>
  
  <p>Firefox:</p>
  
  <blockquote>
    <p>Timestamp: 11/12/2013 2:15:31 PM Error: TypeError: o is undefined
    Source File:
    <a href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" rel="nofollow">http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js</a>
    Line: 9</p>
  </blockquote>
  
  <p>Chrome:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'settings' of undefined</p>
  </blockquote>
  
  <p>Now I've done this a million times and so I figure it's something really simple. I thought maybe I had conflicting versions of jquery and jquery-ui but I went and downloaded the legacy code and I got the same error.</p>
  
  <p>What I don't understand is the datepicker gets initialized and I can make it appear when clicking on the input field but it breaks as soon as I try to interact with it... Any idea what I'm doing wrong here?</p>
  
  <p>Edit: I ran it with unminified code.</p>
  
  <p>Firefox:</p>
  
  <blockquote>
    <p>Timestamp: 11/12/2013 2:34:45 PM Error: TypeError: inst is undefined
    Source File: <a href="http://code.jquery.com/ui/1.10.3/jquery-ui.js" rel="nofollow">http://code.jquery.com/ui/1.10.3/jquery-ui.js</a> Line: 8574</p>
  </blockquote>
  
  <p>Line 8574:</p>
  
  <pre><code>inst.selectedDay = inst.currentDay = $("a", td).html();
  </code></pre>
  
  <p>Unfortunately that doesn't tell me much. I'm not doing anything particularly fancy. I have no other javascript included, this is a very barebone page.</p>