1

jQuery ui autocomplete array should:

find fiddle demo

var availableTags = [
    "How are you doing?",
    "What are you doing?",
    "What did you eat today?",
    "Be Yourself",
    "Try new things"
];

These variables should come from .text() question form a tag.

<a class="toggle FAQCategory" href="">How are you doing?</a>
<a class="toggle FAQCategory" href="">What are you doing?</a>
<a class="toggle FAQCategory" href="">What did you eat today?</a>
<a class="toggle FAQCategory" href="">Be Yourself</a>
<a class="toggle FAQCategory" href="">Try new things</a>

I hope you got what I want.

I don't want to static input in jQuery ui arrays it should come dynamically is per text of question a tag.

find fiddle

1

2 Answers 2

1

In my opinion, You can keep availableTags array. Do this,

var availableTags =[];
$(".FAQCategory").each(function(){
 availableTags.push($(this).text());
 });

so availableTags will iterate all anchor tags with class FAQCategory. Hope it helps.

Sign up to request clarification or add additional context in comments.

Comments

1

Since source requires data as an array and .map() returns an array and it can be used like this

source: function( request, response ) {
  // .map will iterate through each .FAQCategory element and return its text content 
  // and automatically pushes into an array
  var data = $('.FAQCategory').map(function(){ return $(this).text(); }); 
  response( data );
}

Updated demo http://jsfiddle.net/dhirajbodicherla/fdyz3whd/2/

Comments

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.