axel
axel

Reputation: 4127

Jquery autocomplete keyboard navigation set the Value in input, how to change field?

This is my code of a very simple autocomplete

var club_ajax_success = function (data) {
  $("input#sm_autosearch_clubteam").autocomplete({
    source: data,
    select: club_autocomplete_select
  });
  $('input#sm_autosearch_clubteam').prop('disabled', '').prop('placeholder', 'Zoek een club');
};

this is the structure of one single record of my autocomplete store

if i use my keyboard arrows to navigate in the dropdown, displayed after i start to type on my <input>, the effect is that in the input type is shown the value of the record, but I would like the autocomplete to display the label, or at least i would like to remove the possibility to navigate with arrows.

some suggestions?

Upvotes: 1

Views: 3814

Answers (1)

axel
axel

Reputation: 4127

here's the solution

$("input#sm_autosearch_clubteam").autocomplete({
  source: improvedSearchData,
  select: club_autocomplete_select,
  focus: function(event, ui) {
    $('input#sm_autosearch_clubteam').val(ui.item.label);
    return false;
  }
});

Upvotes: 3

Related Questions