Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I write one item in the result array in one place and the rest in another? #367

Open
claracena opened this issue Jan 7, 2019 · 0 comments

Comments

@claracena
Copy link

Hi,

I have the following script:

$('#usuario-buscar').typeahead({
minLength: 4,
highlight: true,
autoSelect: false,
source: function (query, result) {
$.ajax({
url: "user-filter.php",
data: 'query=' + query,
dataType: "json",
type: "POST",
success: function (data) {
result($.map(data, function (item) {
$('#usuario-buscar-id').val(item['user_id']);
return(item['apellido'] + ' ' + item['primer_nombre'] + ' - ' + item['nombre_usuario']);
}));
}
});
}
});

What I need to to is return the formatted result to the .typeahead textbox but the id of the selected item in another "hidden" textbox. Is it possible? In the example I get one of the possible IDs but not the one I select from the list.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant