Autocomplete Custom Vars
by Eric M
JavaScript
$('.PhoneBookUpdateSearch').autocomplete({
source: "/Handlers/PhoneBookSearch.ashx",
minLength: 2,
// what to do when the user is selected from the list
select: function (event, ui) {
SetUpdateScreenState(ui);
}
})
// used to actually show data in drop down list during autocomplete
.data("autocomplete")._renderItem = function (ul, item) {
var displayDept;
if (item.Division == null || item.Division == '') {
displayDept = item.Dept;
} else {
displayDept = item.Dept + ' - ' + item.Division;
}
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.FirstName + " " + item.LastName + ": " + displayDept + "</a>")
.appendTo(ul);
};