title: How can I extend jQueryUI datepicker to accept an additional argument?
body: <p>I like that jQueryUI datepicker is customizable enough to allow for a button to trigger showing the datepicker, but, unfortunately, it doesn't allow you to customize your own markup.</p>
  
  <p>If I have markup like so:</p>
  
  <pre><code>&lt;span&gt;
      &lt;input type="text" class="datepicker" /&gt;
  &lt;/span&gt;
  &lt;span&gt;
      &lt;button class="datepicker-trigger"&gt;Open&lt;/button&gt;
  &lt;/span&gt;
  </code></pre>
  
  <p>In order to get it the datepicker to show when clicking the button, I'd have to implement the following code:</p>
  
  <pre><code>$('.datepicker').datepicker({
      showOn:'none'
  });
  $('.datepicker-trigger').click( function() {
      $('.datepicker').datepicker('show');
  });
  </code></pre>
  
  <p>Here's a jsFiddle of the above code: <a href="http://jsfiddle.net/P9Qmu/" rel="noreferrer">http://jsfiddle.net/P9Qmu/</a></p>
  
  <p>This is all well and good, but what I <strong>really</strong> want to do is pass the datepicker function an additional argument that specifies an object or selector indicating what element should trigger the showing.</p>
  
  <p>For example, I'd really like to be able to do this:</p>
  
  <pre><code>$('.datepicker').datepicker({
      showOn:'none',
      trigger:'.datepicker-trigger'
  });
  </code></pre>
  
  <p>I know how to extend jQuery to add methods and create plugins, but I'm not sure how (or if it's possible) to modify the allowed arguments in an existing function.</p>
  
  <p>Does anyone know how I could extend <code>$.datepicker</code> to achieve what I'm looking to do or at least point me in the right direction? Any help would be much appreciated.</p>