Browse files

save the complete mention data

  • Loading branch information...
1 parent 9b9852b commit 3f9f311df7421fdfd21982f892089f0e6ff9b4fc @Raven24 committed May 10, 2012
Showing with 10 additions and 9 deletions.
  1. +10 −9 jquery.mentionsInput.js
View
19 jquery.mentionsInput.js
@@ -137,7 +137,7 @@
mentionsCollection = _.compact(mentionsCollection);
}
- function addMention(value, id, type) {
+ function addMention(mention) {
var currentMessage = getInputBoxValue();
// Using a regex to figure out positions
@@ -149,15 +149,11 @@
var start = currentMessage.substr(0, startCaretPosition);
var end = currentMessage.substr(currentCaretPosition, currentMessage.length);
- var startEndIndex = (start + value).length;
+ var startEndIndex = (start + mention.value).length;
- var updatedMessageText = start + value + end;
+ var updatedMessageText = start + mention.value + end;
- mentionsCollection.push({
- id : id,
- type : type,
- value : value
- });
+ mentionsCollection.push(mention);
// Cleaning before inserting the value, otherwise auto-complete would be triggered with "old" inputbuffer
resetBuffer();
@@ -179,8 +175,13 @@
function onAutoCompleteItemClick(e) {
var elmTarget = $(this);
+ var mention = {
+ 'value': elmTarget.attr('data-display'),
+ 'id': elmTarget.attr('data-ref-id'),
+ 'type': elmTarget.attr('data-ref-type')
+ };
- addMention(elmTarget.attr('data-display'), elmTarget.attr('data-ref-id'), elmTarget.attr('data-ref-type'));
+ addMention(mention);
return false;
}

0 comments on commit 3f9f311

Please sign in to comment.