Answer the question
In order to leave comments, you need to log in
Dynamic data insertion in autocomplete?
Friends, good evening. Tell me, please, can someone know how to solve my problem:
there is an input to which jquery autocomplete is attached, I need to read the value from the input and add the first line to the autocomplete list. That is, a person enters a word and he is given values from the database in the list, but you need to dynamically insert the value that he entered into the list. Below I will give a piece of code how I read this value, everything works, but I don’t understand how you can insert this value into the list ... Thanks in advance!
$( "#page_type" ).autocomplete({
source: availableTags,
delay: 0,
search: function(){
var text;
type.unbind();
type.on('keyup',function(){
text = type.val();
console.log(text);
});
}
});
Answer the question
In order to leave comments, you need to log in
You can keep the first value in availableTags empty, and replace it.
Demo: https://jsfiddle.net/my36vsx8/1/
This code is only a couple of lines different from the code in the api.jqueryui.com/autocomplete/#event-response
examples
(see the bottom one)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question