I’m using jQuery UI to create an autocomplete search bar,
I’m attempting to modify the following to populate the list of available tags based on the ID name of elements on the page,
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
];
For example on the page, I will have an element such as
<div class="items" id="Get milk">Don't forget to get milk on way home from work</div>
Once the list is populated with these element id’s and a particular id is autocompleted I will be setting all other elements to display: none;
You will need to use
$("...").mapto transform your source array-like object (in this case a jQuery object filled with DOM nodes matching your.itemsselector) into an array that jQueryUI autocomplete can work with. Something like this should work:Assuming you’re using a
data-idattribute, so your markup would look something like this:Example: http://jsfiddle.net/J5rVP/25/