Programmatically set the selected element Jquery UI autocomplete Combobox?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
39 views
Tell me, please, JQuery experts, because the soared for the third day in fruitless attempts:

1. use page two elements JQueryUI Autocomplete combobox here jqueryui.com/demos/autocomplete/#combobox

2. after selecting the item in the first combobox executes the ajax request, the data is safely come and I fill them the second combobox:


$.each(obtainedData,function(i,item){

options += " + item + ";

});

$("#combobox option").remove(); // removed the old list, which there can be

$("#combobox").append(options).combobox();


3. and I want to programmatically select the first element of the newly formed list.

Nothing!!! Zero reaction to such code:


$("#combobox :first").attr("selected", "selected");


no different variations of it though for a normal HTML select it works great.
by | 39 views

3 Answers

0 like 0 dislike
When you create a combobox() it creates input for entering and displaying values. Try this:
\r
var first = $("#combobox :first"); first.attr("selected", "selected"); $("input").val(first.val()); 

Just replace the selector to "input" on your code.
by
0 like 0 dislike
I think you can help events .change (s) and/or .focus()
by
0 like 0 dislike
Take any fresh idea, only more specific, please.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
4 answers
110,608 questions
257,186 answers
0 comments
28,072 users