title: Jquery datepicker button tabindex
body: <p>I'm using the Jquery date/datetimepicker add-on(s), as well as JQgrid.
  I'd like the onShow for the date/datetimepicker to be 'button', but when tabbing through the modal, the date/datetime button mustn't get focus.</p>
  
  <p>Iv'e written a function to create the datepicker for me.</p>
  
  <pre><code>function CreateDatePicker(elem, ShowOn) {
      setTimeout(function () {
          $(elem).datepicker({
              dateFormat: 'yy/mm/dd',
              autoSize: false,
              showOn: ShowOn,
              changeYear: true,
              changeMonth: true,
              showButtonPanel: true,
              showWeek: true,
              onClose: function (dateText, inst) {
                  $(this).focus();
              }
          });
      }, 100);
  
      $(elem).mask("9999/99/99", { placeholder: "_" });
  }
  </code></pre>
  
  <p><strong>I call it like this.</strong></p>
  
  <pre><code>initDateEdit = function (elem) {
          CreateDatePicker(elem, 'button');
  };
  </code></pre>
  
  <p><strong>JQgrid code</strong></p>
  
  <pre><code>{ name: 'Date', index: 'Date', editable: true, formoptions: { rowpos: 1, colpos: 2 }, formatter: 'date', formatoptions: { newformat: 'Y/m/d' }, datefmt: 'Y/m/d', editoptions: { dataInit: initDateEdit }, searchoptions: { dataInit: initDateSearch } },
  </code></pre>
  
  <p>I saw that the datepicker renders like this</p>
  
  <pre><code>&lt;input type="text" id="Date" name="Date" role="textbox" class="FormElement ui-widget-content ui-corner-all hasDatepicker"&gt;
  &lt;button type="button" class="ui-datepicker-trigger"&gt;...&lt;/button&gt;
  </code></pre>
  
  <p>So my initial idea was to latch on to the button class and use Jquery to jump to the next (input) element on the page, regardless of what it is.</p>
  
  <p>I've tried a couple of things, all yielding either incorrect/no results at all...</p>
  
  <p><strong>My last failed attempt...</strong></p>
  
  <pre><code>    $(document).delegate('.ui-datepicker-trigger', 'focus', function (event) {
          $(this).next().focus();
      });
  </code></pre>
  
  <p>Any help will be appreciated.. a lot :)</p>