Trying to add an editor button that is similar to the Smilies button.


Active member
Hi Guys,

I'm trying to create a new button in the editor which will be similar to the Smilie button. I've managed to add the button correctly but the callback just doesn't seem to be firing. Everything else seems to work as it should..

!function($, window, document, _undefined)

    XenForo.customEditorForMyAddon = function($textarea) { this.__construct($textarea); };

    XenForo.customEditorForMyAddon.prototype =
        __construct: function($textarea)
            var redactorOptions = $'options'),            /*Get the current data options from the textarea element*/
            myButtons = this.createCustomButtons(),                    /*Get your custom buttons - see below function*/
            myOptions = {                                /*Bake your custom Editor Options */
                buttons: myButtons                            //Redactor buttons

            if(typeof RedactorPlugins == 'undefined')                /*If your plugins are not loaded before the framework this line should avoid to break the code*/
                RedactorPlugins = {};

            $'options', $.extend(redactorOptions, myOptions));    /*Merge your custom Editor Options with the current ones*/
        createCustomButtons: function()
                Some functions should be static, ie: wrapSelectionInHtml
                wrapSelectionInHtml should have an option to allow to set BbCode Options or Content
            return {
                myCustomButton_1: {
                    title: 'Symbols',                /*This is the button description*/
                    callback: function()
                        alert('symbols called successfully.');
                },                            /*You can instead of the "tag" key use the "exec" key to execute an execCommand*/
                myCustomButton_2: {
                    title: 'Latex',
                    tag: 'LATEX'

    XenForo.register('textarea.BbCodeWysiwygEditor', 'XenForo.customEditorForMyAddon');    /*target all textareas with Redactor loaded*/

}(jQuery, this, document);
I've got the basic understanding from a thread ( which @r1pe and @cclaerhout seem to know alot about.. Hopeone someone knows what is preventing this callback from firing.