像AutoSuggest这样的JQuery Facebook,由"@"触发
我正在寻找一个JQuery(或其他框架)插件,其工作方式类似于Facebook状态消息文本框.
I'm looking for a JQuery (or other framework) plugin, kind of working like the Facebook status message text box.
它应该做什么:
-
允许在不触发AutoSuggest的情况下自由键入文本(与普通的AutoSuggest框相对)
Allow text to be typed freely without triggering the AutoSuggest (as opposed to normal AutoSuggest boxes)
在由某个字符(例如"@")触发时显示自动建议.
Show the AutoSuggest, when triggered by a certain character, such as '@'.
实际上,它的工作方式应与FaceBook中的工作方式完全相同...:)
Actually, it should work exactly like the one in FaceBook ... :)
我将使用以下内容: http://www.codeproject.com/KB/aspnet/Search_SuggestTextBox.aspx
I would use something like this: http://www.codeproject.com/KB/aspnet/Search_SuggestTextBox.aspx
该库的优点是它是由文本输入的 onkeyup 触发的.这意味着您可以更改其提供的JS函数以检查正确的按键顺序
The good thing about this library is that it is triggered by the text input's onkeyup. This means you can alter their provided JS function to check for the correct key sequence
也许是这样的:
var shiftDown=false; //Track if SHIFT was the last key pressed.
function searchSuggest(e)
{
var key = window.event ? e.keyCode : e.which;
if (key==40 || key==38)
{
shiftDown=false;
scrolldiv(key);
}
else if (key == 16) // SHIFT WAS PRESSED
{
shiftDown=true;
}
else if (key == 50 && shiftDown) // 2 WAS PRESSED
{
if (searchReq.readyState == 4 || searchReq.readyState == 0)
{
var str = escape(document.getElementById('txtSearch').value);
strOriginal=str;
searchReq.open("GET", 'Result.aspx?search=' + str, true);
searchReq.onreadystatechange = handleSearchSuggest;
searchReq.send(null);
shiftDown=false;
}
}
else
{
shiftDown=false;
}
}