I'm using Bootstrap 2.1.1 and jQuery 1.8.1 and trying to use Typeahead's functionality.
I try to display a label and use an id like a standard <select />
Here is my typeahead initialization:
$(':input.autocomplete').typeahead({
source: function (query, process) {
$('#autocompleteForm .query').val(query);
return $.get(
$('#autocompleteForm').attr('action')
, $('#autocompleteForm').serialize()
, function (data) {
return process(data);
}
);
}
});
Here is the kind of JSON that I'm sending
[{"id":1,"label":"machin"},{"id":2,"label":"truc"}]
How can I tell process()
to display my labels and store the selected ID in another hidden field?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…