I am mostly a backend developer. And very new to javascript. So pardon my dumb question, but is there a way to trigger autocomplete when the user types '@' in a textfield. Like how it does in twitter.
-
take a look at http://flipnotes.net/notes/note/6/ – suhailvs Jan 30 '15 at 04:50
4 Answers
Take a look at onkeyup if you are using straight javascript. If you are using jQuery, try keyup.
From there, you can check to see if the user entered '@' and then make your auto-complete .
-
I wish I could mark both as correct. The other post was posted earlier thats why I marked it correct. Thank you so much for your answer though :) – Jonathan Oct 12 '12 at 19:07
Got two answers for you:
I think this blog post has what you need: Triggered @mention Autocomplete like Facebook, Twitter and Google+
Github repo: https://github.com/Hawkers/triggeredAutocompleteAlso a similar question: Twitter-style autocomplete in textarea
You could easily do it with http://complete-ly.appspot.com
just override the function onTextChange like this:
function onTextChange(text) {
if (text.lastIndexOf('@') == text.length-1) { // ends with...
// set the options, possibly change the text...
}
}

- 189
- 1
- 2
I've created a Meteor package for this purpose. Meteor's data model allows for fast multi-rule searching with custom rendered lists. If you're not using Meteor for your web app, (I believe) you unfortunately won't find anything this awesome for autocompletion.
Autocompleting users with @
, where online users are shown in green:
In the same line, autocompleting something else using !
with metadata and bootstrap icons:
Fork, pull, and improve:

- 35,740
- 23
- 143
- 224