8

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.

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

2 Comments

What? Not only are those options not listed on the link from js1568, but they don't even work. ?? Why is this here?
How to deal with event and ui when changes occurs?
6

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

Autocomplete has its own events that you should use.

1 Comment

I don't see any callback function in provided link. You should mention at least one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.