Reputation: 3236
Let I search hello world in a jquery autocomplete implemented textbox. My system has this keyword so autocomplete show this keyword as suggestion, but I want to add a new option hello world.
Please, see the picture bellow to understand what I want.
Upvotes: 1
Views: 269
Reputation: 8584
See http://jsfiddle.net/01rbk4cx/
You can use response
which is run after the search is finished and before the selection is shown; http://api.jqueryui.com/autocomplete/#event-response
Just use the callback and add your input's value to the search result:
$( "#tags" ).autocomplete({
source: availableTags,
response: function(e, ui){
ui.content.push({ label: $("#tags").val(),
value: $("#tags").val()});
}
})
Upvotes: 3