im trying to implement mention using (@) on a textarea that feeds from MySQL database. this is the code im using below
var start=/@/ig; // @ Match
var word=/@(\w+)/ig; //@abc Match
$("#newstatus").live("keyup",function()
{
var content=$(this).val() //Content Box Data
var go= content.match(word); //Content Matching @
var name= content.match(word); //Content Matching @abc
var dataString = 'searchword='+ name;
//If @ available
if(go.length>0)
{
$("#msgbox").slideDown('show');
$("#display").slideUp('show');
$("#msgbox").html("Type the name of someone or something...");
//if @abc avalable
if(name.length>0)
{
$.ajax({
type: "POST",
url: siteurl + "ajax/mention", // Database name search
data: dataString,
cache: false,
success: function(data)
{
$("#msgbox").hide();
$("#display").html(data).show();
}
});
}
}
return false;
});
The problem happens when i add more text it keeps showing suggested box, i want to stop searching whenever i start a new sentence after the @WORD im using e.g.
@blackberry is my favorite smartphone !
i may use more than one mention in that textarea ! i want your help how do i do that whenever i use @ then i have suggested list whenever i choose i can continue writing and may use another mention