如何在laravel中获取Ckeditor文本区域值

问题描述 投票:0回答:4
laravel fckeditor
4个回答
2
投票

您的视图包含 post_content 字段(文本区域)的 2 个名称属性。请检查。


0
投票

你可以这样做-

{!! Form::textarea('tc', $tc,array('required', 'class'=>'form-control', placeholder'=>'Your message')) !!}

然后你必须初始化它

$(document).ready(function () {
     CKEDITOR.replace( 'tc' );
  });

0
投票

文档有清晰的示例。

在你的 Blade 中你应该像这样添加 ckeditor:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>A Simple Page with CKEditor</title>
        <!-- Make sure the path to CKEditor is correct. -->
        <script src="../ckeditor.js"></script>
    </head>
    <body>
        <form>
            <textarea name="editor1" id="editor1" rows="10" cols="80">
                This is my textarea to be replaced with CKEditor.
            </textarea>
            <script>
                // Replace the <textarea id="editor1"> with a CKEditor
                // instance, using default configuration.
                CKEDITOR.replace( 'editor1' );
            </script>
        </form>
    </body>
</html>

因此 javascript 代码会触发编辑器中文本区域的替换

现在是检索数据部分

<script>
    var data = CKEDITOR.instances.editor1.getData();

    // Your code to save "data", usually through Ajax.
</script>

如果您想通过 Ajax 发送此数据,您需要创建一个端点。不要忘记添加 CSRF 令牌


0
投票

正如@user3888958所提到的,

© www.soinside.com 2019 - 2024. All rights reserved.