Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top