3

How to get a list of the items for autocomplete? I mean, the source values (hints for autocomplete). I tried this:

$("#autocomplete").autocomplete('option', 'source');

But this doesn't work.

Sorry for my poor Enlish and poor jQuery knowledge.

5
  • 2
    do you want to set items for autocomplete or want to get selected values? Commented Sep 8, 2015 at 5:10
  • 'source' in quotes? Commented Sep 8, 2015 at 5:13
  • When we initialize autocomplete we give it some values. Hints. For example, ["Python", "Perl", "Java", "Basic"]. I need to get this values. Commented Sep 8, 2015 at 5:13
  • read about autocomplete here jqueryui.com/autocomplete Commented Sep 8, 2015 at 5:14
  • 1
    Luthando Loot, please, I need a more concrete link, than link to a whole manual. Commented Sep 8, 2015 at 5:17

2 Answers 2

4

If you wanna to set item for autocomplete

Try like this

$("#autocomplete").autocomplete({

 source : ["dum1","dum2"]

});

After initialize

for getting

var source = $( "#autocomplete" ).autocomplete( "option", "source" );
console.log(source)

for setting

$( "#autocomplete" ).autocomplete( "option", "source", [ "dum3", "dum4", ] );
Sign up to request clarification or add additional context in comments.

4 Comments

No, i need to GET items. Get suggestions for autocomplete.
nope. Just [element]. The output is just like $("#autocomplete").
can you provide the initialize part ? i think i got your problem
Unfortunately, I can't. But if you tell me, what are you thinking about, I'll be very grateful.
0
var source = $( ".selector" ).autocomplete( "option", "source" )

console.log(source) 

response: ['val1','val2','val3']

1 Comment

While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.