I'm using Tagit! with jQuery autocomplete.
It works a treat, retrieving known search words from a database as long as the user clicks one of the returned words.
If, however, user ↓s and hits enter, the tag is created but the value/Id from the selected item is not stored. In other words, the "select" method is ignored, and this is critical. I have attempted a slew of keypress detections, but none work.
var theTags = $('#Keywords');
theTags.tagit({
allowSpaces: true,
autocomplete: {
source: function (request, response) {
$.ajax({
url: webroot + "handlers/ACKeyword.ashx",
dataType: "json",
data: {
q: request.term.replace($('#hdnFound').val().trim(), "").trim()
},
success: function (data) {
response($.map(data.what, function (item) {
return {
label: item.name,
id: item.id
}
}));
}
});
},
select: function (event, ui) {
// Doesn't fire on enter?
itemId = ui.item.id;
theTags.tagit("createTag", ui.item.value);
$('#hdnKey').val($('#hdnKey').val().trim() + "," + ui.item.id);
return false;
}
}
},
})
You can tell a bad coder by how angry they get when their code doesn't work.