Closed w4ugit closed 3 years ago
Most likely you need to re-initialize the editor.
Most likely you need to re-initialize the editor.
how to do it if i call it just as a widget?
<?= TinyMce::widget([ 'options' => [ 'rows' => $model->options['rows'], 'placeholder' => true, 'data-role' => 'widgetEditor' ], 'model' => $model->model, 'attribute' => $model->attribute, 'language' => 'ru', 'clientOptions' => [ 'menubar' => false, 'statusbar' => true, 'theme' => 'modern', 'skin' => 'lightgray-gradient', //charcoal, tundora, lightgray-gradient, lightgray 'plugins' => [ "advlist autolink lists link image charmap print preview hr anchor pagebreak placeholder", "searchreplace wordcount visualblocks visualchars code fullscreen", "insertdatetime media nonbreaking save table contextmenu directionality", "emoticons template paste textcolor colorpicker textpattern imagetools codesample toc noneditable", ], 'noneditable_noneditable_class' => 'fa', 'extended_valid_elements' => 'span[class|style]', 'toolbar1' => "bold italic underline| bullist numlist", 'image_advtab' => true, 'content_css' => [ '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i', '//www.tinymce.com/css/codepen.min.css', ] ], 'fileManager' => [ 'class' => MihaildevElFinder::className(), ] ]); ?>
Before loading the editor, you must delete the existing one.
View:
$script = "
let url = '$url';
// Load editor via ajax
$('#load').on('click', function(){
$.ajax({
url: url,
type: 'post',
}).done(function (response) {
$('#editor').html(response);
}).fail(function (response) {
console.log(response);
});
});
// Remove
$('#remove').on('click', function(){
tinymce.remove();
$('#editor').text('');
});
";
$this->registerJs($script);
<button id="load">Load Editor</button>
<button id="remove">Remove Editor</button>
<div id="editor"></div>
I upload content using renderAjax (). When I do it for the first time - everything works well, the editor is displayed. But when I try to download content again via renderAjax () (without reloading the page) - the editors are not displayed