Google Closure: Setting Input for AutoComplete Dynamically

Posted by amuzed on Stack Overflow See other posts from Stack Overflow or by amuzed
Published on 2010-03-19T00:13:06Z Indexed on 2010/03/19 0:41 UTC
Read the original article Hit count: 518

The Google Closure (GC) Javascript Library makes it very easy to create an AutoComplete UI, as this demo shows - http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/autocomplete-basic.html .

Basically, all we have to do is define an array and pass it on as one of the parameters. I'd like to be able to update the array dynamically and have AutoComplete show the changes immediately.

Example, if there are two arrays

list1 = ["One", "Two", "Three"]
list2 = ["1", "2", "3"]

and an AutoComplete has been initialized using list1,

var suggest = new goog.ui.AutoComplete.Basic(list1, document.getElementById('input'), false);

how can I update the existing AutoComplete (suggest) to use list2?

© Stack Overflow or respective owner

Related posts about google-closure-library

Related posts about javasript