简体   繁体   中英

jQuery Autocomplete on select of a menu item, how to override the focus back into the input?

I'm trying to extend the jQuery autocomplete plugin with something as simple as:

Superbox = {

//Options to be used as defaults
options:{
    triggerStart:"@",
    triggerEnd:"",
    position: { my : "left bottom", at: "left top" }
},

_init: function() {
      // stuff
},

_create:function() {
    this.triggered = false;

    this.element.autocomplete($.extend({

        open: function(event, ui) {
 .....

$.widget("ui.autocompleteTrigger", Superbox);

Right now I can't figure out how to override the situation where you see the autosuggest menu, you select an item and the textarea gets focus. How can I override that focus? I can't find where that binding is in the pluin? After an autosuggest item selection, I want to focus on a different element.

Thank you

You can use the select callback function for this. Something like this should work:

select: function(){ $('input#id').blur(); }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM