I\'m trying to get jQueryUI AutoComplete to trigger on dynamically created form input elements, but it\'s not working. I\'ve tried using keyup.autocomplete and keydown.autoc
This works:
$(function() {
var options = {
source: [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
],
minLength: 2
};
$("input.searchInput").live("keydown.autocomplete", function() {
$(this).autocomplete(options);
});
var addInput = function() {
var inputHTML = " ";
$(inputHTML).appendTo("form#myForm");
$("input.searchInput:last").focus();
};
if (!$("form#myForm").find("input.searchInput").length) {
addInput();
}
$("input#addButton").click(addInput);
});