Answer the question
In order to leave comments, you need to log in
Programmatically make Jquery UI Combobox autocomplete item selected?
Tell me, please, JQuery experts, because I've been struggling for the third day in fruitless attempts:
1. I use two JQueryUI Autocomplete combobox elements on the page from here jqueryui.com/demos/autocomplete/#combobox
2. after selecting an element in the first combobox, ajax is executed - request, the data arrives safely and I fill the second combobox with them like this:
$.each(obtainedData,function(i,item){
options += "" + item + "";
});
$("#combobox option").remove(); // removed the old list that might be there
$("#combobox").append(options).combobox();
3. and I want to programmatically select the first element of the newly formed list.
Nothing!!! Zero reaction to code like this:
$("#combobox :first").attr("selected", "selected");
nor for various variations of it, although for a regular HTML select it works with a bang.
Answer the question
In order to leave comments, you need to log in
When creating a combobox() , an input is created to enter and display the value. Try like this:
var first = $("#combobox :first");
first.attr("selected", "selected");
$("input").val(first.val());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question