title: TimeSpinner Check If Undefined Not Working
body: <p>Currently I have a an input text field that may or may not have a timespinner tied to that particular element. In some cases, I need to remove the timespinner functionality altogether (as opposed to disabling it), to display it properly on the page.</p>
  
  <p>Currently, I have code to check if the timespinner exists on the element as follows:</p>
  
  <pre><code>if ($("#ElementOfInterest").timespinner !== undefined){
      $("#ElementOfInterest").timespinner("destroy");
  }
  </code></pre>
  
  <p><strong>This works fine when the page is first loaded</strong>, however, this throws the following exception:</p>
  
  <blockquote>
    <p>cannot call methods on timespinner prior to initialization; attempted
    to call method 'destroy'</p>
  </blockquote>
  
  <p>For some reason, the check for <code>undefined</code> passes and tries to a timespinner on the element that doesn't exist. </p>
  
  <p>So the only way for my UI to run properly at the moment is to wrap it in a <code>try/catch</code> block like this:</p>
  
  <pre><code>if ($("#ElementOfInterest").timespinner !== undefined) {
      try {
          $("#ElementOfInterest").timespinner("destroy");
      } catch (error) {
      }
  }
  </code></pre>
  
  <p>This works, but it is rather sloppy. I would rather have the check be successful and remove the <code>try/catch</code> block from the code.</p>
  
  <p>Am I missing some special check or something? What's going on here?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I tried the following code suggested by @GlenSwift:</p>
  
  <pre><code>if (typeof $("#ElementOfInterest").spinner("instance") !== 'undefined') {
      $("#ElementOfInterest").timespinner("destroy");
  }
  </code></pre>
  
  <p>This however, gave me this exception:</p>
  
  <blockquote>
    <p>cannot call methods on spinner prior to initialization; attempted to
    call method 'instance'</p>
  </blockquote>
  
  <p>I also tried <code>timespinner("instance")</code> but I simply got back:</p>
  
  <blockquote>
    <p>undefined is not a method</p>
  </blockquote>
  
  <p>So it looks like checking for an instance of a timespinner was not implemented.</p>