StudioTime
StudioTime

Reputation: 23999

Jquery autocomplete - do not fill input box with result

I am using the standard Jquery UI Autocomplete which works great.

I have a form with input ID of autoc1

When a list of matches is returned I use onlick on the results to automatically direct a user to another page, which is filled dynamically based on their choice.

When they click though, I would like the input to not be filled but simply wait for the onclick to fire.

So basically clicking on a result does fill the input element with anything - is this possible?

This is the code I use to invoke the call:

$("#autoc1").autocomplete("/autoc.php?arg=1&user=<? echo $user; ?>");

Then trying the following but simply not working

$("#autoc1").autocomplete({
select: function(event, ui){
    $('#autoc_buddy1').css('color','white');    
}
});

Also tried

$("#autoc1").autocomplete({
select: function(event, ui) { return false; }
});

Didn't work

Upvotes: 1

Views: 1843

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100195

I guess you could use the select Event of Autocomplete. You can use return false to cancel copying the suggestion to the textbox. Like,


$( ".selector" ).autocomplete({
   select: function(event, ui) { return false; }
});

Did you mean something like this. Hope it helps

Upvotes: 3

Related Questions