The below autocomplete function returns all users from associative $filteredUsersArray instead of what I type in html input tag. I only need to get the user I'm looking for. The function(request) is being executed correctly depending on what I type into input. The code works for standard, non-associative array. I'm passing associative array with user id's to then use the id for POSTing private message.
autocomplete function:
$userSearchbox.autocomplete({
source: function(request, response) {
response($.map($filteredUsersArray, function (value, key) {
return {
label: value.username,
value: key.id
}
}));
}
});
$filteredUsersArray:
[{
"id": "1",
"userName": "maciek"
}, {
"id": "2",
"userName": "stefan"
}, {
"id": "3",
"userName": "newuser"
}, {
"id": "8",
"userName": "papaitalia"
}, {
"id": "9",
"userName": "nowy_user"
}, {
"id": "12",
"userName": "zenek"
}]
