title: Can't access combodate from JS function
body: <p>I suspect that the problem I'm having is just a misunderstanding of JS scope or something.</p>
  
  <p>I have moment.js and combodate.js linked and the following code works fine when run immediately after my form:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function(){
          $('#birthday').combodate();
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>But if I want to run it in a function (to clear the form, for instance):</p>
  
  <pre><code>var launchChildRegisterModal = function() {
      //Do other stuff...
      $('#birthday').combodate();
  }
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>TypeError: $(...).combodate is not a function
  </code></pre>
  
  <p>Do I have to do something special to use it from within a function?</p>
  
  <p>EDIT: to clarify, the following code does work:</p>
  
  <pre><code>&lt;form id="register-form" action='&lt;?= base_url('user/register/' . issetor($invite_code, '')) ?&gt;' method="POST"&gt;
          &lt;!-- Account Type hidden form element--&gt;
          &lt;input type="hidden" name="account_type" class="form-control" id="account_type" value="&lt;?= issetor($_GET['account_type'], '') ?&gt;" /&gt;
  
          &lt;div class="control-group"&gt; 
            &lt;!-- First Name --&gt; 
            &lt;!--&lt;label class="control-label"  for="first_name"&gt;First Name&lt;/label&gt;--&gt;
            &lt;div class="controls"&gt;
              &lt;input type="text" id="first_name" name="first_name" placeholder="First Name" value="&lt;?=isset($set_values['first_name'])? $set_values['first_name'] : ''?&gt;" required&gt;
              &lt;p class="help-block"&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group" id="last_name_group"&gt; 
            &lt;!-- Last Name --&gt; 
            &lt;!--&lt;label class="control-label"  for="last_name"&gt;Last Name&lt;/label&gt;--&gt;
            &lt;div class="controls"&gt;
              &lt;input type="text" id="last_name" name="last_name" placeholder="Last Name" value="&lt;?=isset($set_values['last_name'])? $set_values['last_name'] : ''?&gt;"&gt;
              &lt;p class="help-block"&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group" id="username_group" style="display: none;"&gt; 
            &lt;!-- Username --&gt; 
            &lt;!--&lt;label class="control-label" for="username"&gt;Username&lt;/label&gt;--&gt;
            &lt;div class="controls guidingText"&gt;
              &lt;input type="text" id="username" name="username" placeholder="Username" value="&lt;?=isset($set_values['username'])? $set_values['username'] : ''?&gt;"&gt;
              &lt;p&gt;Username can contain any letters or numbers, but must be 20 characters or less.&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group" id="email_group"&gt; 
            &lt;!-- Email --&gt; 
            &lt;!-- &lt;label class="control-label" for="email"&gt;Email &lt;/label&gt;--&gt;
            &lt;div class="controls"&gt;
              &lt;input type="text" id="email" name="email" placeholder="Email" value="&lt;?= issetor($set_values['email'], issetor($parent_email, '')) ?&gt;"&gt;
              &lt;p class="help-block"&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group" id="gender_group" style="display: none;"&gt; 
            &lt;!-- Gender --&gt;
            &lt;!--&lt;label class="control-label"  for="gender"&gt;Gender&lt;/label&gt;--&gt;
            &lt;div class="controls"&gt;
              &lt;select name="gender" id="gender" class="genderSelect" value="&lt;?=isset($set_values['gender'])? $set_values['gender'] : 'Gender'?&gt;"&gt;
                &lt;option&gt;Gender&lt;/option&gt;
                &lt;option&gt;Male&lt;/option&gt;
                &lt;option&gt;Female&lt;/option&gt;
              &lt;/select&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group" id="birthday_group" style="display: none;"&gt; 
            &lt;!-- Birthday --&gt; 
            &lt;div class="controls input-append date"&gt;
            &lt;p&gt;Birthday&lt;/p&gt;
              &lt;input type="text" id="birthday" class="bdateSelect" name="birthday" placeholder="Birthday" data-format="MM/DD/YYYY" data-template="MMM / D / YYYY" value="&lt;?= date('m/d/Y') ?&gt;"&gt;
              &lt;span class="add-on"&gt;&lt;i class="icon-th"&gt;&lt;/i&gt;&lt;/span&gt;
              &lt;p class="help-block"&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group" id="parent_email_group" style="display: none;"&gt; 
            &lt;!-- Parent Email --&gt; 
            &lt;!-- &lt;label class="control-label" for="parent_email"&gt;Parent Email&lt;/label&gt;--&gt;
            &lt;div class="controls guidingText"&gt;
              &lt;input type="text" id="parent_email" name="parent_email" placeholder="Parent Email" value="&lt;?=isset($set_values['parent_email'])? $set_values['parent_email'] : ''?&gt;"&gt;
              &lt;p&gt;If not available, leave blank for now.&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="control-group"&gt; 
            &lt;!-- Password --&gt; 
            &lt;!-- &lt;label class="control-label" for="password"&gt;Password&lt;/label&gt;--&gt;
            &lt;div class="controls guidingText"&gt;
              &lt;input type="password" id="password" name="password" placeholder="Password" pattern="^\S{8,}$" required title="Password must be 8 characters or more."&gt;
              &lt;p&gt;Password must be at least 8 characters&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group"&gt; 
            &lt;!-- Password Confirmation --&gt; 
            &lt;!--&lt;label class="control-label"  for="password_confirm"&gt;Confirm Password&lt;/label&gt;--&gt;
            &lt;div class="controls"&gt;
              &lt;input type="password" id="password_confirm" name="password_confirm" placeholder="Confirm Password" minlength="8" pattern="^\S{8,}$" onchange="check(this)"  required&gt;
              &lt;p class="help-block"&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  
            &lt;div class="control-group"&gt; 
            &lt;!-- Password Confirmation --&gt; 
            &lt;!--&lt;label class="control-label"  for="password_confirm"&gt;Confirm Password&lt;/label&gt;--&gt;
            &lt;div class="controls"&gt;
              &lt;input type="zip" id="zip" name="zip" placeholder="Zip Code" minlength="5" pattern="^\d{5,}$" onchange="check(this)"&gt;
              &lt;p class="help-block"&gt;&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="control-group"&gt; 
            &lt;!-- Submit Button --&gt;
              &lt;button class="button3" id="form-submit-btn"&gt;Sign Up&lt;/button&gt;
          &lt;/div&gt;
        &lt;/form&gt;
        &lt;script type="text/javascript"&gt;
          $(function(){
              $('#birthday').combodate();
          });
        &lt;/script&gt;
  </code></pre>
  
  <p>but further down the page I have the launchChildRegisterModal() function above which throws the error.</p>