javascript - 如何从 php 中的 suneditor textarea 发送值?

标签 javascript php ckeditor text-editor

我想在 php 中发送 textarea 值 Suneditor

PHP代码

if($_POST["submit"]){
    $content =  $_POST["txtEditor"];
    echo $content;
}

HTML代码

 <form action="" method="post" >
        <textarea id="txtEditor" name="txtEditor" style="display:none;"></textarea>
        <input type="submit" name="submit" class="submit">
    </form>

Javascript

$(document).ready(function() {
    $("#txtEditor").Editor();
    $('form').submit(function () {
        $('#txtEditor').val($('#txtEditor').Editor('getText'));
    });
    $('#txtEditor').Editor('setText', $('#txtEditor').val());
});

suneditor.create('txtEditor', {
    buttonList: [
        ['undo', 'redo', 'removeFormat'],
        [align, font, fontSize, fontColor, hiliteColor],
        [horizontalRule, image, template]
    ],
})

编辑器工作完美。
我哪里做错了?

最佳答案

完整代码

const description = SUNEDITOR.create((document.getElementById('description')),{
            buttonList: [
                ['undo', 'redo'],
                ['bold', 'underline', 'italic'],
                ['removeFormat'],
                ['outdent', 'indent'],
                ['align', 'list'],
                ['table'],
                ['fullScreen', 'showBlocks']
            ],
            lang: SUNEDITOR_LANG['pl']
        });
        $(window).click(function() {
            document.getElementById('description').value = description.getContents();
        });

关于javascript - 如何从 php 中的 suneditor textarea 发送值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64214787/

相关文章:

重构期间的 PHP 命名空间最佳实践?

php - CKEditor 和 CkFinder 在 PHP 中工作正常,但不显示图像、flash 等

javascript - 从没有名称和 ID 值的元素分离 CK 编辑器

javascript - 如何将属性值调用到javascript

php - 使用 php、ffmpeg 和 proc_open 逐帧读取视频

php - laravel 应用程序中的 beanstalkd 驱动程序配置错误

ssl - 带有 SCAYT over HTTPS 的 CKEditor 给出安全警告

javascript - CKEDITOR 在 IE 上 getElementsByTag 时丢失自定义节点

javascript - H1 中的随机彩色词

javascript - 在 For in 循环中渲染复选框并在 Vue JS 中绑定(bind)它们的值