Triggered @mention Autocomplete like Facebook, Twitter and Google+
Asked Answered
M

6

5

I have been trying to make something like Facebook @tagged Friend name add in text area. I have been using jquery ui auto-complete to do the job , it's working fine except that I want some symbol such as @ or ~ to start the tag, I can't figure it out how. Anyone has ideas ? I'm using it for multiple tag of friends just like Facebook.

Marimaria answered 26/3, 2012 at 10:40 Comment(3)
Can you show what you have tried so far ?Paulo
possible duplicate of autocomplete in middle of text (like Google Plus)Castro
you can see similar plugins at hereUnaware
H
8

I wrote a plugin to accomplish this:

http://www.hawkee.com/snippet/9391/


$('#inputbox').triggeredAutocomplete({
    hidden: '#hidden_inputbox',
    source: "/search.php",
    trigger: "@" 
});
Harshman answered 6/5, 2012 at 3:50 Comment(0)
D
5

You can use a bootstrap plugin library that I wrote. It works on ContentEditable divs: http://sandglaz.github.com/bootstrap-tagautocomplete/

Dillie answered 26/3, 2013 at 16:21 Comment(0)
O
1

Here's another one (triggered by a starting character like @) http://www.9lessons.info/2010/08/tag-friends-with-jquery-ajax-and-php.html

Ochre answered 5/6, 2013 at 16:33 Comment(0)
S
1

THIS MAY BE USEFUL a sample one., : http://jsfiddle.net/suneeshtr/6ymLD/1/ also check :http://www.hawkee.com/snippet/9391/

Standup answered 11/2, 2014 at 10:32 Comment(1)
Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference.Edinburgh
E
0

Hey you can try something like this ... Hope it works..

$q=$_POST['searchword'];
$q=str_replace("@","",$q); 
$q=str_replace(" ","%",$q);
$sql_response=mysql_query("select * from data where fname like '%$q%' or lname like '%$q%'");
while($row=mysql_fetch_array($sql_response))
{
  $fname=$row['fname'];
  $lname=$row['lname'];  
}
Endstopped answered 26/3, 2012 at 16:27 Comment(0)
M
0

I'm a couple of years late, but I figured I'd add my two cents since it doesn't appear as if anyone has actually answered the question yet ;) .

The source option of jQuery UI Autocomplete is used to specify an array containing the items that are to be displayed in the drop-down list once the widget is triggered. It can be defined as such an array, a function that returns such an array, or a URL to a resource which produces such an array.

If the array which ultimately becomes the value of source is empty, the widget won't display a drop-down list. So, defining source as a function capable of returning a non-empty array only when @ is entered will make the widget behave as you desire.

If you don't want to go through the trouble of defining such a function, have a look at Mentionator, a jQuery plug-in which provides mention creation and management functionality (as well as helpful auxiliary features) that actually builds on top of the functionality of jQuery UI Autocomplete. Its maintained by yours truly :) .

Mhd answered 2/7, 2016 at 20:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.