在PHP中使用innerHTML加载TinyMCE

Based on a selected option the code prints an textarea on the complemento1 div:

        if ($_GET["t"]==1) /// Text
    {
        $str="";
        $str.="<table width=100%>";
            $str.="<tr>";
                $str.="<td>";
                    $str.="Digite aqui o texto que será exibido:";
                $str.="</td>";
            $str.="<tr>";
                $str.="<td>";
                    $str.="<textarea id='texto' name='texto' rows=3 cols=80>".$row["texto"]."</textarea>";
                $str.="</td>";
        $str.="</table>";
        echo "<script>window.parent.document.getElementById('complemento1').innerHTML=\"".$str."\";</script>";
    }

Now I want to add an TinyMCE editor, but my attempts failed, I've tried to put the code on the PHP file:

    <script src="/_assets/editor/vendor/tinymce/tinymce/tinymce.min.js"></script>
    <script type="text/javascript">tinymce.init({mode: 'textareas', language: 'pt_BR', menubar: '', statusbar: false});</script>

Despite "Mode: textareas" nothing happens... If I call the init inside my code:

<script>window.parent.document.getElementById('complemento1').innerHTML=\"".$str."\"; tinymce.init({mode: 'textareas', language: 'pt_BR', menubar: '', statusbar: false});</script>

Got the error on the console:

Uncaught ReferenceError: tinymce is not defined
at 

^^^ It is already defined on my PHP! ( at head)

Where did I go wrong? How can I define TinyMCE correctly?

查看全部
dongni9825
dongni9825
2019/02/21 13:54
  • php
  • tinymce
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复