I have following method which gets online agents and put them in auto complete, user clicks from the auto complete box to pickup the name. But on click its always taking the last name from the array: msg.db
(click Roaxana or Roman, picks always Rubin)
function ___________other_tasks(input) {
switch(keyboard_mode) {
case 'show_all_agents':
$('#select_box_users').html('');
$.post(submit_url + '/zendframework/agentslist', {
firstname: $('#keyboard_input').val(),
}, function(msg) {
__cache = msg.db;
for(_key in msg.db) { // Suppose i have 3 agents, on click each of them it only shows the last record value
let $clickme = $('<div class="agents_list">' + msg.db[_key].firstname + ' ' + msg.db[_key].lastname + '</div>');
$clickme.click( () => click_agent_list(msg.db[_key].id, msg.db[_key].firstname, msg.db[_key].lastname ) );
$('#select_box_users').append($clickme);
}
}, 'json');
break;
}
}
function click_agent_list(input, input1, input2) {
alert(input1); // shows last value
}