[jQuery] [autocomplete] Autocompletion in dynamic inputs
Hello,
i'm using the autocomplete plugin (http://docs.jquery.com/Plugins/
Autocomplete) on my site. On static inputs, it worked fine:
HTML:
<form autocomplete="off">
<input type="text" id="suggest" />
<input type="button" value="Search" OnClick="something()" />
</form>
jQuery:
$(document).ready(function()
{
$("#suggest").autocomplete('searchbox', {
width: 210,
multiple: false,
matchContains: false,
formatItem: formatItem,
formatResult: formatResult
});
});
But now, I want to create an dynamic Input:
HTML:
<li id="addnewtag"><a href="javascript:addTag()">Add new Tag</a></li>
jQuery/Javascript:
function addTag()
{
$("li#addnewtag").before('<li><form autocomplete="off"><input
type="text" id="suggest_addtag" /></form></li>');
}
This works fine again. But all tries to enable autocomplete for this
imput were not (realy) successful.
The ready-function isn't fired again, and the new live()-function
worked, but not realy good. The suggestions are not displayed all
times as they should. :-(
I hope, someone could help me?!
Thanks