Closed kwazaro closed 6 years ago
Hello @kwazaro !
I suppose that you are trying to attach the script to existing textareas inputs like in this section: https://github.com/vova07/yii2-imperavi-widget#like-a-widget-for-a-predefined-textarea by using css classes
.
If that's the way you are trying to use it, then you should switch to css ids
and make each input unique on your page.
To be able to help you, I need more info, so if that's possible, please provide more details.
No, I'm using widget in ActiveForm within foreach
like this:
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'parent_id')->textInput() ?>
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
<?php foreach (Yii::$app->urlManager->languages as $key => $language) { ?>
<?= $form->field($model->translate($language), "[$language]content")->widget(Redactor::class, [
'settings' => [
'minHeight' => 500,
],
]);
<?php } ?>
<?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success btn-flat']) ?>
<?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger btn-flat pull-right',
'data-method' => 'post',
'data-confirm' => Yii::t('app', 'Do you really want to delete this Item?'),
]) ?>
<?php ActiveForm::end(); ?>
In source code, produced by page, I can see the Redactor inits like this:
jQuery("#pagelang-ru-content").redactor({"minHeight":500...
jQuery("#pagelang-uk-content").redactor({"minHeight":500...
jQuery("#pagelang-en-content").redactor({"minHeight":500...
I just checked your code and it works fine.
I have one question: did you rename the extension in your use statements like:
use vova07\imperavi\Widget as Redactor
or you are using the different extension?
I renamed it in use vova07\imperavi\Widget as Redactor
@kwazaro can you please provide the message of error you get in your web console? I'm not able to reproduce this bug.
FYI: Your code work as expected for me with multiple inputs.
I use bootstrap nav-tabs here, and when I switch to another tab, the Redactor actually seems to appear, but without tools panel. Tools panel is present only on one tab. No javascript errors or messages in console.
I suppose that it's related with the case when the redactor is initiated for an inexistent input yet. Probably that at the point of time the redactor is initiated the additional inputs are not yet rendered, and that cause such issue. Can you please try without tabs, to confirm it's the main reason, so we'll can investigate further.
You are right! Without nav-tabs its working on all textareas. So what's the deal, how do you think? Maybe, there is a possibility to init Redactor after DOM complete?
I cannot provide a fast answer, I need to test it.
Do you use any kind of extensions for nav-tabs
or just the direct bootstrap functionality?
I use only Bootstrap 3 from Yii2 defaults.
Hey @kwazaro !
I've just tested your use case, and I wasn't able to reproduce the issue even using the nav-tabs
.
Can you please share the real code you use, or maybe you can provide the demo code which can prove the issue.
Without that demo I'll not be able to help you.
If you say, that you wasn't able to reproduce this bug, than it seems to be some my project specific case, I close this issue, If I will find the solution, I will post it here. Thanks for help.
If you say, that you wasn't able to reproduce this bug, than it seems to be some my project specific case, I close this issue, If I will find the solution, I will post it here. Thanks for help.
I have the same problem. No solution?
got the same problem works fine without nav-tabs. if i put them in separate nav tabs most of the time only first is rendered fine. if you need more info or code just shout. greetings bvdv
When I add Widget to multiple textareas on the same page, the Redactor works only for first one. How to use Redactor in multiple instances on the same page for different textareas?