JQuery UI Datepicker loses focus when selecting date with mouse

后端 未结 10 1565
情歌与酒
情歌与酒 2021-02-01 02:16

I am using JQuery ui with datepicker and when a user tabs on to a field, they appropriately get the calendar pop up.

  1. User tabs (via key onto field
  2. User s
10条回答
  •  旧巷少年郎
    2021-02-01 02:54

    Thanks for the suggestion Jeff, I modified your onSelect function to use the attribute filter to retrieve only elements with the tabindex specified by "nexttab".

    $(function(){
      $(".date").datepicker({
          onSelect: function(){
              currenttab = $(el).attr("tabindex");
              nexttab = currenttab * 1 + 1;
              $("[tabindex='" + nexttab + "']").focus();
          }
      });
    });
    

    PS: If you don't have tabindexes specified in your code, like I neglected to do earlier, simply add the following code:

    $('input, select').each(function(i, val){
        $(this).attr('tabindex', i + 1);
    });
    

提交回复
热议问题