StevenDevooght / tinyMCE-mention

Mention/Autocomplete plugin for tinyMCE WYSIWYG editor.
http://stevendevooght.github.io/tinyMCE-mention/
220 stars 95 forks source link

Two instances on same page #26

Closed joshbenhamou closed 8 years ago

joshbenhamou commented 9 years ago

Hi, thanks for the great plugin

I'm attempting to have two instances on the same page. Unfortunately, although they are set up exactly the same way (except for different ids) the mention dropdown is not showing on the second one. I've included my code for one below. Any advice?

tinymce.init({
    mode: 'exact',
    selector:'textarea#edit_comment_textarea',
    menubar: false,
    toolbar: false,
    statusbar: false,
    plugins: 'autoresize, mention',
    mentions: {
        source: function (query, process, delimiter) {
            if (delimiter === '@') {
                app_api.execute_api_get('/api/user/account', {
                    cols: 'status: active, firstname, surname',
                    ignore_current: true
                }, 'users', function(api_result, me){
                    var length = api_result.users.length,
                        result = [];

                    for (var i = 0; i < length; i++) {
                        result.push({
                            name: api_result.users[i].firstname + ' ' + api_result.users[i].surname
                        });
                    }
                    process(result);
                }, me);
            }
        },
        insert: function(item) {
            return '<span>[~' + item.name + '~]</span>';
        }
    },
    setup : function(ed) {
        ed.on('change', function(e) {
            if (ed.getContent() != '') {
                me.comment_form_validation.valid_comment = true;
            } else {
                me.comment_form_validation.valid_comment = false;
            }
        });
    }
});
StevenDevooght commented 9 years ago

Hi @joshbenhamou,

I will look into this issue.

StevenDevooght commented 9 years ago

@joshbenhamou I created a sample fiddle with two instances on one page. Both instance properly show the mention dropdown.

Can you submit a fiddle reproducing your problem?