dasdasd
dasdasd

Reputation: 2031

JQuery autocompleted does not clear the input after select

I want my input field to be cleared after the user select the input from the autocopmleted I have searched for answers on stackoverflow and none of the answers work for me. Here is my code:

  $("#fastSearchInput").autocomplete({   
                    source: users,
                    select: function (suggestion, ui)
                    {
                        id = ui.item.data;
                       window.open("member.php?id="+id,'_blank');
                       $(this).val("");
                       event.preventDefault();
                    }});

Upvotes: 0

Views: 57

Answers (1)

bassxzero
bassxzero

Reputation: 5041

Change the name of your select handler's first parameter to event. E.G

$("#fastSearchInput").autocomplete({   
  source: users,
  select: function (event, ui)
  {
    id = ui.item.data;
    window.open("member.php?id="+id,'_blank');
    $(this).val("");
    event.preventDefault();
  }});

Upvotes: 1

Related Questions