0

I am working on a AutoComplete search bar that reads from an array. I am needing to parse a JSON file and push the names into an array. I have everything working except for the right command to push to the actual array. What would I use to push to the array below?

    $("#schoolLocal").autocompleteArray(
    [],
    {
        delay:10,
        minChars:1,
        matchSubset:1,
        onItemSelect:selectItem,
        onFindValue:findValue,
        autoFill:true,
        maxItemsToShow:10
    }
);

I used $("#schoolLocal").autocompleteArray.push(name);

And of course that didn't work.

Any help is appreciated. Thank you!

Dan Rivers
  • 173
  • 3
  • 14
  • Why not just use a standard library's autocomplete functionality like [jQueryUI autocomplete](http://jqueryui.com/autocomplete/). – Bruno Nov 16 '12 at 16:40
  • Why aren't you using jQuery Autocomplete? – Shmiddty Nov 16 '12 at 16:42
  • Are you using this library - http://www.pengoworks.com/workshop/jquery/autocomplete.htm, or is it your own jQuery plugin that has the `autocompleteArray` method? – Pebbl Nov 16 '12 at 17:00

1 Answers1

0

what is autoCompleteArray? an array or a function?

Assuming it's an array then:

// declare the array  with 2 sub arrays,1 for names and other for definitions (?)
$("#schoolLocal").autocompleteArray = new Array(new Array(),{
        delay:10,
        minChars:1,
        matchSubset:1,
        onItemSelect:selectItem,
        onFindValue:findValue,
        autoFill:true,
        maxItemsToShow:10
    }
);

//push to the names array
$("#schoolLocal").autocompleteArray[0].push(name);
JDuarteDJ
  • 1,073
  • 12
  • 25