jQueryUI autocompleteTrigger

http://stackoverflow.com/q/4564378/497356

by dmattes

HTML

<link rel="stylesheet" href="http://ajax.microsoft.com/ajax/jquery.ui/1.8.5/themes/humanity/jquery-ui.css">
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="https://rawgithub.com/experteer/autocompleteTrigger/master/jquery-ui.autocompleteTrigger.js"></script>
<script src="https://rawgithub.com/accursoft/caret/master/jquery.caret.js"></script>
<h2>Textfield</h2>
<input type='text' />

<div>&nbsp;</div>

<h2>Textarea</h2>
<textarea col="50" row="3"></textarea>

<h2>Editable Div</h2>
<div contenteditable="true" id="ce-div"></div>

CSS

input, textarea { width: 300px; }
div[contenteditable=true]{
    border: 1px solid black;
    height: 30px;
}

JavaScript

$('input,textarea,div').autocompleteTrigger({
  source: [
    "Asp",
    "BASIC",
    "COBOL",
    "ColdFusion",
    "Erlang",
    "Fortran",
    "Groovy",
    "Java",
    "JavaScript",
    "Lisp",
    "Perl",
    "PHP",
    "Python",
    "Ruby",
    "Scala",
    "Scheme"
  ]
});