podio / jquery-mentions-input

MIT License
985 stars 333 forks source link

I can't get this to work with custom templates / data #141

Open ProLoser opened 9 years ago

ProLoser commented 9 years ago

So it's a little bit frustrating that my data MUST have a name property and that you completely obfuscate this in all of your code by copying it to a value property.

I also am having difficulty trying to get custom templates working so that I can show additional / different data:

      $element.mentionsInput({
        elastic: false,
        allowRepeat: true,
        templates: {
          mentionItemSyntax: _.template('@[<%= uuid %>.<%= businesses[0].uuid %>.<%= businesses[0].neighborhood.uuid %>]'),
          autocompleteListItemAvatar : _.template('<img src="<%= profile_image.small_url %>" />'),
          mentionItemHighlight       : _.template('<strong><span><%= first_name %></span></strong>'),
          autocompleteListItem       : _.template('<li data-ref-id="<%= uuid %>" data-ref-type="<%= type %>" data-display="<%= display %>"><%= first_name %> <%= last_name %><br><small class="text-muted"><%= businesses[0].name %></li>'),
        },
    });

I just get empty/blank rows or no rows at all

varun-raj commented 8 years ago

This worked for me :

templates : { mentionItemSyntax : _.template('[<%= value %>](/profile/<%= id %>)'), },

ProLoser commented 8 years ago

I just ended up building this myself: https://github.com/angular-ui/ui-mention