views:

33

answers:

1

Is there a module that already exists or can someone point me in the right direction for creating an autocomplete that works similar to Facebook's status update where you have standard text mixed in with autocompleted names that are activated by a delim character such as @. Plus, all of this placed within an editable div or multiline textarea?

Thanks

A: 

One option could be to use the jQuery autocomplete plugin. http://www.devbridge.com/projects/autocomplete/jquery/#intro

jQuery(function(){ 
  $('textarea').autocomplete({
    serviceUrl:'/autocomplete.php', 
    delimiter: /\s*[@]/,
    deferRequestBy: 0,
    minChars:2}); 
});

This will call autocomplete.php?query=userinput when the user entered "@userinput" into the textarea and the php script should return a JSON object containing all names starting with userinput as well as the original query.

{
 query:'userinput',
 suggestions:['userinput1','userinput2','userinput3','userinput4'] 
}
nxt