jakiestfu / mention.js Goto Github PK
View Code? Open in Web Editor NEWLightweight wrapper for adding @user mention functionality to Twitter Bootstraps Typeahead plugin
Home Page: http://jakiestfu.github.com/Mention.js/
License: MIT License
Lightweight wrapper for adding @user mention functionality to Twitter Bootstraps Typeahead plugin
Home Page: http://jakiestfu.github.com/Mention.js/
License: MIT License
Is there a way to set the preferred position somehow?
I have the following users values:
{ username: "AniSales", name: "Ani Sales" }, { username: "BonnięSales", name: "Bonnię Sales" },
If I type @AniSales all works well and the auto-complete finishes. I I type @bonn the autocomplete starts, but if I hit enter it does not finish.
I have had this problem with various Polish characters in the username.
Is there a way to re-initialize a textarea with a new data (user list) or add more user data? At the moment reusing .mention(...)
on an element doesn't do anything!
I have some user names like this -> john.smith
When I select those type of user names and try to type more stuff with out entering the delimiter it always pops open the modal. When I select a username with out a period then it works fine.
How to mention same user again
Typeahead is linked to bootstrap's github page. Not a major problem but to clear the confusion it is good to fix for newbies who doesn't know the difference.
How do I retrieve the data? For example, if I use the Name, Username, & Image example,
and @username gets inserted into the table. How do I retrieve the full data array on form submission or for an ajax call?
there are a way of enable multiple users ?
Here is how it looks on my page
This is what I use
jQuery("#field_5").mention({
users: [
{
name: 'Lindsay Made',
username: 'LindsayM',
image: 'http://placekitten.com/25/25'
},
{
name: 'Rob Dyrdek',
username: 'robdyrdek',
image: 'http://placekitten.com/25/24'
},
{
name: 'Rick Bahner',
username: 'RickyBahner',
image: 'http://placekitten.com/25/23'
},
{
name: 'Jacob Kelley',
username: 'jakiestfu',
image: 'http://placekitten.com/25/22'
},
{
name: 'John Doe',
username: 'HackMurphy',
image: 'http://placekitten.com/25/21'
},
{
name: 'Charlie Edmiston',
username: 'charlie',
image: 'http://placekitten.com/25/20'
},
{
name: 'Andrea Montoya',
username: 'andream',
image: 'http://placekitten.com/24/20'
},
{
name: 'Jenna Talbert',
username: 'calisunshine',
image: 'http://placekitten.com/23/20'
},
{
name: 'Street League',
username: 'streetleague',
image: 'http://placekitten.com/22/20'
},
{
name: 'Loud Mouth Burrito',
username: 'Loudmouthfoods',
image: 'http://placekitten.com/21/20'
}
]
);
I also include recommended CSS file.
Is this possible to point users to an external json file ?
When you type in the same username in the same text field it does something weird: for example: When I want to type this: "@tomaszed91 but this plugin has a bug @tomaszed91", when I going to type the second time and I press enter it ends up like this: "@tomaszed91aszed91 but this plugin has a bug @tom", Im using bootstrap on Rails 3.2, thanks
I have an updated version of mention.js and you can get it using bower as well.
I have following code :
var following_list;
$.ajax({
type :"POST",
url:"http://linkzone.dev/ajax/follower/select",
data: '',
dataType : 'json',
cache: false,
async:false,
success:function(result){
following_list = result;
},
error: function(xhr, textStatus, errorThrown) {
}
});
$("#usermention").mention({
delimiter: '@',
queryBy: ['name', 'username'],
users: following_list
});
AJAX request return following data :
[
{
"name":"Reagan Dietrich",
"username":"Reagan8"
},
{
"name":"Ashlynn Powlowski",
"username":"Ashlynn4"
},
{
"name":"Tejas Kulkarni",
"username":"tejas"
}
]
Now when I use trigger like @tejas and after that even though I put a space bar/enter key still it shows up the typeahead , also it deletes any further text .
When i use it with queryBy: ['username'] It works fine .
Hi there,
We are using bootstrap 3, so the typeahead is now split out. It seems like this plug in doesn't work with the split out version, is there plans to fix it, or a simple workaround?
Thanks!
Brent
Hello there, great plugin, very useful and thanks to work on it.
I have a situation that I need to figure out and your plugin fit with my scenario, but there some questions that I need answers.
Thanks again
Is there an option to have a callback after selecting a mention item from the list? Twitter Typeahead (not the bootstrap version) has a selected
event, but Mention.js doesn't seem to work with Typeahead....?
Thanks!
Mention.js has a great user experience. We're evaluating whether to sacrifice the wysiwyg textfield and make it a plain html textarea element to use it, since it seems to be working with textareas only.
What would it take to allow it to work with rich-text editing enabled elements?
Given the following code...
$(".comment-box").mention({
sensitive: true,
users: [{
username: "sarah"
}, {
username: "bigRat"
}, {
username: "roger"
}, {
username: "Ricky"
}]
});
When I type @h
I end up with items
in the _render
function equaling
[function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
},
Object
username: "sarah"
__proto__: Object
, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}]
If I type @s
instead I get
[
Object
username: "sarah"
__proto__: Object
, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}, function () {
return this.sort(function() {
return 0.5 - Math.random();
});
}]
I'm not sure what is going on.
I'm having trouble getting this to work with my Wysiwyg editor, which renders as an editable
If we have "isaac" and "isaac2". When mentioning "isaac", the menu still there offering "isaac2". But I'd like to select "isaac" and hide the menu.
Typing first two letters "mu", the first result is "HackMurphy" instead of "mutmaurice"...
$("#full").mention({
sensitive:true,
users:
[{
name: 'Lindsay Made',
username: 'LindsayM',
image: 'http://placekitten.com/25/25'
}, {
name: 'Rob Dyrdek',
username: 'robdyrdek',
image: 'http://placekitten.com/25/24'
}, {
name: 'Rick Bahner',
username: 'RickyBahner',
image: 'http://placekitten.com/25/23'
}, {
name: 'Jacob Kelley',
username: 'jakiestfu',
image: 'http://placekitten.com/25/22'
},{
name: 'John Doe',
username: 'HackMurphy',
image: 'http://placekitten.com/25/21'
}, {
name: 'Maurice',
username: 'mutmaurice',
image: 'http://placekitten.com/25/21'
}, {
name: 'Charlie Edmiston',
username: 'charlie',
image: 'http://placekitten.com/25/20'
}, {
name: 'Andrea Montoya',
username: 'andream',
image: 'http://placekitten.com/24/20'
}, {
name: 'Jenna Talbert',
username: 'calisunshine',
image: 'http://placekitten.com/23/20'
}, {
name: 'Street League',
username: 'streetleague',
image: 'http://placekitten.com/22/20'
}, {
name: 'Loud Mouth Burrito',
username: 'Loudmouthfoods',
image: 'http://placekitten.com/21/20'
}]
});
For example handle both "@" for users and "#" for hashtags :)
Is there a way to limit number of users/entities mentioned ? I want to allow only 1 user to be mentioned in my status/post, how can I achieve this?
Could you add an example for using mention.js
with a function setting the users array?
Love this plugin by the way. Super easy to use.
I realized that this is a duplicate of issue #13 but I wanted to let you know that it's still incorrect on the live demo using the user with the handle @charlie
.
http://jakiestfu.github.io/Mention.js/
Here is the code and the description of the bug:
$(".mention").mention({
queryBy: ['username', 'name'],
users: [{
username: "bob",
name: "Bob Frank",
image: "some image"
}, {
username: "jones",
name: "Jones Wilson",
image: "some image"
}]
});
Then if I type something like "yay, @bob
is awesome" after I choose bob, the list remains showing for that one user. If I only use username
as queryBy
this phenomenon doesn't occur.
What's weird is that if I give the username
a value that is not a substring of the first name like bubba
for Bob Frank
this issue doesn't occur:
$(".mention").mention({
queryBy: ['username', 'name'],
users: [{
username: "bubba",
name: "Bob Frank",
image: "some image"
}, {
username: "jicama",
name: "Jones Wilson",
image: "some image"
}]
});
This works as expected. I'm looking into the code to see if I can figure out a fix, but if this is known or if you know why this is happening, I could sure use a hand getting it solved.
It should show whole list of users if typeaheadOpts: { minLength: 0 }
is set. Thoughts?
It would be nice to also have mention be able to handle emoji and hash tags on the same textarea. I tried just running it twice on the same textarea but it didn't work.
http://jakiestfu.github.io/Mention.js/ last example. If you select for example @AndreaM you cannot select him again...
how to ignore email entries when using @ token? Just use: delimiter: '(^|\\s)@'
option. Please add it to description or fix issue right in plugin code.
It should point to here instead:
https://github.com/twitter/typeahead.js
$("textarea#id").mention({
user: get_mentions()
});
The _get_mentions()_ returns following data in console log:
[{"name":"waqas","username":"waqas","image":"http://1.gravatar.com/avatar/af6946f5faf8414bb87112f5dbcfd0be?s=96&d=mm&r=g"},{"name":"waqas","username":"waqas","image":"http://1.gravatar.com/avatar/af6946f5faf8414bb87112f5dbcfd0be?s=96&d=mm&r=g"},{"name":"waqas","username":"waqas","image":"http://1.gravatar.com/avatar/af6946f5faf8414bb87112f5dbcfd0be?s=96&d=mm&r=g"},{"name":"waqas","username":"waqas","image":"http://1.gravatar.com/avatar/af6946f5faf8414bb87112f5dbcfd0be?s=96&d=mm&r=g"},{"name":"admin","username":"admin","image":"http://0.gravatar.com/avatar/c647c51159fd78634f029028ea542fec?s=96&d=mm&r=g"},{"name":"admin","username":"admin","image":"http://0.gravatar.com/avatar/c647c51159fd78634f029028ea542fec?s=96&d=mm&r=g"},{"name":"admin","username":"admin","image":"http://0.gravatar.com/avatar/c647c51159fd78634f029028ea542fec?s=96&d=mm&r=g"},{"name":"admin","username":"admin","image":"http://0.gravatar.com/avatar/c647c51159fd78634f029028ea542fec?s=96&d=mm&r=g"}]
The autocomplete search is not working when delimiter is set to '$'
$('#formula').mention({ delimiter: '$', emptyQuery: true, users: users: [{ username: 'LindsayM' }, { username: 'robdyrdek' }, { username: 'RickyBahner' }, { username: 'jakiestfu' }, { username: 'HackMurphy' }, { username: 'charlie' }, { username: 'andream' }, { username: 'calisunshine' }, { username: 'streetleague' }, { username: 'Loudmouthfoods' }] });
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.