I’m using the jQuery autocomplete
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
Though what I would like to do is get rid of the availableTags and make it so it searches within say div.post h3.username And from there get the users names. Also I want to use this for a textarea is this possible?
Next question is is it possible to make this only work when you first write @ then the users like @T will show up all the T users?
If you have every username you’d like to use in “div.post h3.username”, then you have to create a list with all the usernames (similar to the one you want to get rid of) but more information is needed regarding how those names are contained in that element if you want more help with that.
As for using @ to retrieve usernames, depends on what you want. For example, if you insist that a new box must appear containing suggested usernames next to the written text, then it’s not possible with textareas. This is because there is no cross-browser solution to localize the coordinates of where you’re writing. Instead of a textarea, you have to use a div with a contenteditable attribute. However, if you’re willing to have those usernames contained in another div below your textarea, then it’s quite possible. If you want to describe what you are expecting, maybe I can provide some code.
You may want to prefer this kind of autocompletion, though.