I’m using jquery UI AutoComplete to allow users to tag friends using @mentions. By default, the autocomplete suggestions appear when as soon you put focus on the textbox. How can you make the suggestions appear only when you type “@”? This is the code I have so far:
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
];
$("#tags").autocomplete({
source: availableTags,
minLength: 0
});
You can do this by providing a function to the
sourceoption of autocomplete:Here’s a working example: http://jsfiddle.net/BfAtM/2/
Note that this is almost identical to this demo, except for the requirement for the user to type “@”. That code is located inside the
sourceoption argument.Hope that helps.