Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 845
Carlos Blanco Avatar asked Jun 16 '11 18:06

Carlos Blanco


1 Answers

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.

like image 86
Carlos Blanco Avatar answered Oct 13 '22 12:10

Carlos Blanco