Created
July 11, 2012 20:11
-
-
Save hcmn/3092967 to your computer and use it in GitHub Desktop.
JQuery UI: Autocomplete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the array we are going to use for our autocomplete text | |
// box. Notice, it's just one big array! This one for example is | |
// filled with a lot of names of programming languages. | |
var availableTags = [ | |
"ActionScript", | |
"AppleScript", | |
"Asp", | |
"BASIC", | |
"C", | |
"C++", | |
"Clojure", | |
"COBOL", | |
"ColdFusion", | |
"Erlang", | |
"Fortran", | |
"Groovy", | |
"Haskell", | |
"Java", | |
"JavaScript", | |
"Lisp", | |
"Perl", | |
"PHP", | |
"Python", | |
"Ruby", | |
"Scala", | |
"Scheme" | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Autocomplete!</title> | |
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/base/jquery-ui.css"/> | |
</head> | |
<body> | |
<div class="ui-widget"> | |
<label for="tags">Tags: </label> | |
<input id="tags"> | |
</div> | |
</body> | |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js" type="text/javascript"></script> | |
<script src="autocomplete-options.js"></script> | |
<script src="script.js"></script> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//autocomplete using JQuery UI | |
//credit: Benjamin Clifford, Codecademy | |
$(function() { | |
// | |
// Add the code for selecting the #tags input and set the source | |
// for the autocomplete to be 'availableTags' which are set in | |
// autocomplete-options.js | |
$('#tags').autocomplete({ | |
source: availableTags | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment