DataSource
Two DataSource instances point to in-memory JavaScript arrays. The first
array holds the 50 US states. The second array itself holds arrays of US
area codes and their corresponding states.
AutoComplete
Since the two DataSources for this example are already loaded into memory
via JavaScript arrays, queries should be very fast to return data. Therefore,
both AutoComplete instances are configured to have a query delay of zero
seconds.A few configurations have also been made to aid the usability of the
widgets. The autoHighlight and typeAhead features can help reduce the number
of user actions it takes to submit a valid selection. The
prehighlightClassName feature provides an supplemental visual feedback for mouse
events.
Additionally, the second AutoComplete instance also has been enhanced to
display two data fields in the container: the area code and the area code's
state. The forceSelection feature has been enabled to prevent the user from
typing in a free-form selection.
Sample Code
CSS:
Markup:
JavaScript: