JQuery UI Datepicker loses focus when selecting date with mouse

jquery, jquery-ui

Solution

Subscribe to the `onClose` or the `onSelect` event:

$("#someinput").datepicker(
{
    // other options goes here
    onSelect: function ()
    {
        // The "this" keyword refers to the input (in this case: #someinput)
        this.focus();
    }
});

Or in the case of `onClose`:

$("#someinput").datepicker(
{
    onClose: function ()
    {
        this.focus();
    }
});

Problem

I am using JQuery ui with datepicker and when a user tabs on to a field, they appropriately get the calendar pop up. - User tabs (via key onto field - User selects date with mouse click - User tabs - Tabindex starts over at one (at the beginning of form) Here is code. (May also have the tab index set) ``` <input type="text" name="demo" /> <input type="text" class="date" /> ``` The jquery code is: ``` $(".date").datepicker(); ``` Any suggestions on how I might go about solving this issue (bonus to shortest solution)?

Original source