jQuery autocomplete plugin not focusing the next clicked field

后端 未结 3 590
萌比男神i
萌比男神i 2021-01-23 13:31

I\'m using the Jörn Zaefferer\'s jQuery autocomplete plugin which works great, except for a small bug: if a user begins typing in one field where the autocomplete is attached to

相关标签:
3条回答
  • 2021-01-23 13:52

    The fix is:

    Comment out lines 308-310 of the unpacked version:

    //if (wasVisible)
        // position cursor at end of input field
        //$.Autocompleter.Selection(input, input.value.length, input.value.length);
    

    And from Luca's post, comment out line 510:

    //input.focus();
    

    These both need to be commented out to make it work properly.

    0 讨论(0)
  • 2021-01-23 13:56

    How about if the user uses the Enter-key or the TAB-key? How can I stop the plugin from setting focus in the input field then? You got that to work as well, or only when the user used the mouse to choose from the drop down?

    0 讨论(0)
  • 2021-01-23 14:16

    I've been kind enough to look at the code for you, uncomment this line:

    // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
    input.focus();
    

    In jquery.autocomplete.js line 583.

    0 讨论(0)
提交回复
热议问题