ivirabyan / jquery-mentions

Adds mentioning support to your text fields.
http://ivirabyan.github.io/jquery-mentions/
MIT License
114 stars 49 forks source link

getValue add extra character behind the value. #67

Closed chiragsatapara closed 7 years ago

chiragsatapara commented 7 years ago

Get Value add some extra character after the mention value , here look the image. Click here , red dot indicate the extra character , it save ? into the database. @ivirabyan

ivirabyan commented 7 years ago

Do use ordinary textarea or contenteditable?

chiragsatapara commented 7 years ago

I am using a contenteditable @ivirabyan

chiragsatapara commented 7 years ago

$('#editable').mentionsInput('getValue'); this value return the data which contain u200B , so i use this function to remove that. .replace(/[\u200B-\u200D\uFEFF]/g, '') and now it is working fine , so you have to think on this . @ivirabyan

chiragsatapara commented 7 years ago

this character are zero width character . Refer this stackoverflow link click here @ivirabyan

ivirabyan commented 7 years ago

Yes, I know about this character, it's used to identify mentions within text. Of course this shouln't be returned with getValue() call, it's only part of representation, not what actually must be stored.

chiragsatapara commented 7 years ago

@ivirabyan, it is return with the getValue() , so i just do below change in my code.

 MentionsContenteditable.prototype.getValue = function() {
      var markupMention, value;
      value = this.input.clone();
      markupMention = this._markupMention;
      $(this.selector, value).replaceWith(function() {
        var name, uid;
        uid = $(this).data('mention');
        name = $(this).text();
        return markupMention({
          name: name,
          uid: uid
        });
      });
      return value.html().replace(this.marker, '').replace(/[\u200B-\u200D\uFEFF]/g, '');
    };