Closed Q1WP closed 9 years ago
It seems a much common issue with many developers. When using multiple yii based input widgets on same page remember that most of them init the jquery plugin using HTML ID attr. You must have unique ID attr for all such widgets set via options.
I know.
I am careful to always specify the id
for each attribute to prevent this issue.
The source code here on GitHub doesn't have the constant inputOptions
in the markdown editor like you show in the docs.
But it looks like in the source you are using options
so I am using the following to set the id
and it still doesn't work.
return $form->field($model, $attribute)->widget(MarkdownEditor::classname(), [
//'height' => 300,
'options' => [
'id' => $attribute,
],
'encodeLabels' => false,
'showExport' => false,
'toolbar' => $customToolbar,
'footerButtons' => $footerButtons,
'footerMessage' => $footerMessage1,
]);
I am even setting the id
of the actual buttons:
[
'buttons' => [
MarkdownEditor::BTN_PREVIEW => ['icon' => 'search', 'title' => 'Preview Formatted Text'],
],
'options' => ['class' => 'pull-right', 'id' => 'preview-' . $attribute]
],
[
'buttons' => [
MarkdownEditor::BTN_MAXIMIZE => ['icon' => 'fullscreen', 'title' => 'Toggle Full Screen', 'data-enabled' => true],
],
'options' => ['class' => 'pull-right', 'id' => 'fullscreen-' . $attribute]
],
It seems that the preview
button works correctly now, but the toggle fullscrreen
button only works correctly on the last rendered widget. The toggle fullscreen
button actually will enlarge the window on the first rendered widget, but then the two buttons are disabled and it won't go back to small.
What am I missing?
I have tried over and over to solve this but cant seem to get anywhere.
It is as thought the maximize and preview buttons are disabled when the first rendered editor goes fullscreen.
The preview button works fine on both editors, and the fullscreen button works fine on the second editor, but the first editor will only go fullscreen, not minimize.
I have fixed this issue in my branch...
When using multiple markdown editors in a single view file, only the last rendered editor works properly with the
toggle preview
andtoggle fullscreen
functions.I haven't tested other buttons, but these seem to fail.