dasdasd dasdasd - 2 months ago 6
jQuery Question

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();
}});

Answer

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();
  }});
Comments