@ mention / tag input plugin using plain JavaScript
Demo: demo
<link rel="stylesheet" href="/mention.css">
<script src="/mention.js">
Each option only requires a name field
var myMention = new Mention({
input: document.getElementById('myTextArea'),
options: [
{ name: 'WideEye' },
{ name: 'LiquidLuck' },
{ name: 'PolyJuice' }
]
})
var mentions = myMention.collect()
When defining the mention object add update function
var myMention = new Mention({
...
,
update: function() {
console.log(this.collect())
}
})
When defining the mention object add template function.
var myMention = new Mention({
...
,
template: function(option) {
return '@' + option.name
}
})
When defining the mention object add match function.
var myMention = new Mention({
...
,
match: function(word, option) {
// Match not case sensitive
return option.name.toLowerCase().startsWith(word.toLowerCase())
}
})