yiidoc / yii2-redactor

Extension Redactor WYSIWYG for Yii2 framework
BSD 3-Clause "New" or "Revised" License
186 stars 87 forks source link

Error when trying to use plugins #73

Closed arun-maddheshia closed 1 year ago

arun-maddheshia commented 7 years ago

I'm trying to load the Modal Window and I'm getting this error:

Uncaught ReferenceError: RedactorPlugins is not defined

My code

<?php
$script = <<< JS
(function($)
{
    $.Redactor.prototype.advanced = function()
    {
        return {
            getTemplate: function()
            {
                return String()
                + '<div class="modal-section" id="redactor-modal-advanced">'
                    + '<section>'
                        + '<label>Enter a text</label>'
                        + '<textarea id="mymodal-textarea" style="height: 200px;"></textarea>'
                    + '</section>'
                    + '<section>'
                        + '<button id="redactor-modal-button-action">Insert</button>'
                        + '<button id="redactor-modal-button-cancel">Cancel</button>'
                    + '</section>'
                + '</div>';
            },
            init: function()
            {
                var button = this.button.add('advanced', 'Advanced');
                this.button.addCallback(button, this.advanced.show);
            },
            show: function()
            {
                this.modal.addTemplate('advanced', this.advanced.getTemplate());
                this.modal.load('advanced', 'Advanced Modal', 600);

                var button = this.modal.getActionButton();
                button.on('click', this.advanced.insert);

                this.modal.show();

                $('#mymodal-textarea').focus();
            },
            insert: function()
            {
                var html = $('#mymodal-textarea').val();

                this.modal.close();

                this.buffer.set(); // for undo action
                this.insert.html(html);
            }
        };
    };
})(jQuery);

JS;
$this->registerJs($script);
?>

Advanced plugin script is loaded after redactor.js but don't know why its happen. Please give me some suggestion. Thanks in advance!