I'm working on a summernote editor and trying to implement the "mention" feature by pulling usernames from a database.
match: /\B@(\w*)$/,
mentions:function(keyword, callback) {
$.ajax({
url: document.location.origin+"/topic/groupusers/"+topic_cat,
type: 'GET',
success: function(callback) {
callback = $(callback).filter('.mentiondata').text();
}
});
},
search: function (keyword, callback) {
callback($.grep(this.mentions, function (item) {
return item.indexOf(keyword) == 0;
}));
},
content: function (item) {
return '@' + item;
}
The mention attribute needs to have this format:
mentions: ['jayden', 'sam', 'alvin', 'david'],
when I console.log callback
inside the success function that's what I get. However, it doesn't work on search event and gives me item is undefined
error