Carlos Blanco
Carlos Blanco

Reputation: 8762

JQuery UI Autocomplete callback

Is it possible to define a callback function to an input which JQuery Autocomplete plugin has been applied to.

I actually want to execute something on the onchange event, but, weirdly, it is triggered before the value is set. The input has a blank value when the onchage event is triggered.

Upvotes: 8

Views: 10851

Answers (2)

js1568
js1568

Reputation: 7032

http://api.jqueryui.com/autocomplete/#event-change

Autocomplete has its own events that you should use.

Upvotes: 6

Carlos Blanco
Carlos Blanco

Reputation: 8762

Following js1568 answer. Here it is how.

$('selector').autocomplete({
   .
   .
   .
   change: function (event, ui) { 
       //your code
   },
   close: function (event, ui) { 
       //your code
   }
})

Use the close event too, if you want your code to be triggered after the user selects a value.

Upvotes: 7

Related Questions