Skip to content

Commit

Permalink
save the complete mention data
Browse files Browse the repository at this point in the history
  • Loading branch information
Raven24 committed May 10, 2012
1 parent 9b9852b commit 3f9f311
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions jquery.mentionsInput.js
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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;
}
Expand Down

0 comments on commit 3f9f311

Please sign in to comment.