I want to clear the textbox having Jquery Autocomplete once the user has made the selection.
I tried to clear the field by :
select: function(event, ui) { $(this).val(''); }
But this is not working.I am using jquery-1.6.4 and jquery-ui-1.8.16.
Any Ideas?
addClass("ui-screen-hidden"); which will hide all the autocomplete filtered list upon selecting it.
In that case, you need to define a callback function to the source option of autoComplete call. Also, you can pass multiple parameters using this approach. Your jQuery UI Autocomplete function would be like the following. In the source file, you can get the term and additional parameters using the $_GET variable.
In the process of searching a specific value, the jQuery UI autocomplete selection feature provides the user with some string suggestions for the input area which effectively saves time. The autocomplete select action is triggered when the user selects one of the options from the pre-populated list.
The select event occurs before the field is updated. You will have to cancel the event to avoid the field being updated after you have cleared it:
select: function(event, ui) { $(this).val(""); return false; }
Update: As T.J. pointed out below, it's slightly faster to update the value
DOM property directly instead of going through val():
select: function(event, ui) { this.value = ""; return false; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With