From cd4c68c936e5057c6ffd2a17502fe73cd9c70432 Mon Sep 17 00:00:00 2001 From: Bartosz Kostrowiecki Date: Fri, 17 Feb 2017 13:58:14 +0100 Subject: [PATCH 1/2] Adding rejectFilter to the options. Triggered when matching duplicates. --- jquery.mentionsInput.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.mentionsInput.js b/jquery.mentionsInput.js index e75bb0a..56c231e 100644 --- a/jquery.mentionsInput.js +++ b/jquery.mentionsInput.js @@ -23,6 +23,7 @@ elastic : true, //Grow the textarea automatically defaultValue : '', onCaret : false, + rejectFilter : null, classes : { autoCompleteItemActive : "active" //Classes to apply in each item }, @@ -408,7 +409,9 @@ if(!settings.allowRepeat) { // Filter items that has already been mentioned var mentionValues = _.pluck(mentionsCollection, 'value'); - results = _.reject(results, function (item) { + results = _.reject(results, settings.rejectFilter === 'function' ? function(item) { + return settings.reject(item, mentionsCollection); + } : function (item) { return _.include(mentionValues, item.name); }); } From f7973de21c4b0e9a5fc1c0e318e01b54311695a8 Mon Sep 17 00:00:00 2001 From: Bartosz Kostrowiecki Date: Fri, 17 Feb 2017 14:24:04 +0100 Subject: [PATCH 2/2] Add extra data to 'mention' event --- jquery.mentionsInput.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jquery.mentionsInput.js b/jquery.mentionsInput.js index 56c231e..e513eca 100644 --- a/jquery.mentionsInput.js +++ b/jquery.mentionsInput.js @@ -222,7 +222,10 @@ // Mentions and syntax message var updatedMessageText = start + mention.value + ' ' + end; elmInputBox.val(updatedMessageText); //Set the value to the txt area - elmInputBox.trigger('mention'); + elmInputBox.trigger({ + type: 'mention', + mention: mention + }); updateValues(); // Set correct focus and selection