In this demo: http://jqueryui.com/autocomplete/#multiple

Whenever you manually type in a term and press ", ", the autocomplete automatically displays a list of all terms, which can be troublesome if you have a list of 100,000 terms.

So how do you stop autocomplete from activating after ", "?

And how do you set a minimum length for each term in the input before autocomplete activates?

有帮助吗?

解决方案

To handle events when typing and after searching:

  $('.selector').on( "autocompletesearch", function( event, ui ) {
      var text=$('.selector').val();
      if(text[text.length-1]==',') //This validation will do the trick you want (ie: prevent to load everything after you type a ",")
          event.preventDefault();
  } );

jsfiddle

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top