kartik-v / yii2-editors

Yii2 editor widgets Summernote and Codemirror.
Other
22 stars 7 forks source link

Render problem with ajax loaded content not working Summernote editor #11

Closed dev1-kait closed 3 years ago

dev1-kait commented 3 years ago

@kartik-v

all widgets are working on ajax loaded contents except Summernote WYSIWYG ediror

<?php

/* @var $this \yii\web\View */

/* @var $model \backend\models\Faq */

use backend\models\Faq;
use yii\bootstrap4\ActiveForm;
use yii\bootstrap4\Html;
use yii\helpers\Url;
use common\helpers\ChoiceHelper;
use kartik\select2\Select2;
use common\helpers\LanguageHelper;
use kartik\icons\FontAwesomeAsset;
FontAwesomeAsset::register($this);
use kartik\editors\Summernote;
?>

<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <?php $form = ActiveForm::begin(['id' => 'create-form', 'enableAjaxValidation' => true, 'options' => ['data-target' => 'ajax']]); ?>
        <div class="modal-header">
            <h4 class="modal-title" id="myLargeModalLabel">
                <?= $model->isNewRecord ? Yii::t('app', 'Create Faq') : Yii::t('app', 'Update Faq') ?>
            </h4>
        </div>
        <div class="modal-body">
            <div class="row">
                <div class="col-md-6">
                <?= $form->field($model, 'faq_category_id')->widget(Select2::classname(), [
                        'theme'     =>  Select2::THEME_BOOTSTRAP,
                        'data' => ChoiceHelper::getFaqCategoryChoices(),
                        'options' => [
                            'placeholder' => Yii::t('app', 'Select a category ...'),
                        ],
                        'pluginLoading' => false,
                ])?>
                </div>
                <div class="col-md-6">
                    <?= $form->field($model, 'status')->dropdownList(Faq::getEnumValues('status')) ?>
                </div>
                <div class="col-md-12">
                    <?= $form->field($model, 'title')->textInput() ?>
                </div>
                <div class="col-md-12">
                    <?php //$form->field($model, 'description')->textarea(['rows' => '6']) ?>
                    <?= $form->field($model, 'description')->widget(Summernote::classname(), [
                        'options' => ['placeholder' => 'Edit your blog content here...']
                    ]); ?>
                </div>
                <div class="col-md-6">
                    <?= $form->field($model, 'language')->widget(Select2::classname(), [
                        'theme' => Select2::THEME_BOOTSTRAP,
                        'data' => LanguageHelper::LANGUAGE_CHOICES(),
                        'hideSearch' => true,
                        'options' => [
                            'placeholder' => Yii::t('app', 'Select a language ...'),
                        ],
                        'pluginOptions' => [
                            'allowClear' => true,
                        ],
                        'pluginLoading' => false,
                    ]); ?>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <?= Html::submitButton(
                $model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Save Changes'),
                ['class' => 'btn btn-primary']
            ) ?>
            <button class="btn btn-danger" data-dismiss="modal" id="faq-close"><?= Yii::t('app', 'Close') ?></button>
        </div>
        <?php ActiveForm::end(); ?>
    </div>
</div>

<?php
$this->registerJs(<<<JS
    $('#create-form').on('ajaxSubmit',function(e, data){
       $(this).closest('.modal').modal('hide');
       $.pjax.reload({container: '#list_grid'});
    });
JS
) ?>