views:

31

answers:

1

I'm looking for a JQuery (or other framework) plugin, kind of working like the Facebook status message text box.

What it should do:

  • 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 '@'.

Actually, it should work exactly like the one in FaceBook ... :)

A: 

I would use something like this: http://www.codeproject.com/KB/aspnet/Search_SuggestTextBox.aspx

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

Maybe something like this:

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; 
    }  
}
Dutchie432
Thanks. What about the carot position, can that be retrieved somehow?
Bertvan
Nevermind: http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area and http://plugins.jquery.com/plugin-tags/caret
Bertvan
This gives me a start, thanks!
Bertvan