CKEditor-无法设置属性'dir': object的值为空或未定义

CKEditor- Unable to set value of the property 'dir': object is null or undefined

本文关键字:未定义 object dir 设置 属性 CKEditor-      更新时间:2023-09-26

我已经下载了CKEditor并在我们的MVC项目中使用。请参考以下代码

@{ Html.BeginForm("Save", "News", FormMethod.Post, new {@class="form-inline news-admin"}); }
 <div class="input">@Html.TextBoxFor(x => x.ShortText, new { @class = "shorttext", @id="editor1",maxlength = "50" })</div>
@{ Html.EndForm(); }

CKeditor代码:

<script type="text/javascript">
                CKEDITOR.replace( 'editor1' );
            </script>

,但它抛出错误,如无法设置属性'dir'的值:object在ckeditor.js中为空或未定义。我不知道这个问题的真正原因是什么?我的代码出了什么问题

几件事。不能重写for helper上字段的id。你的选择器永远不会捕获这个域。如果您试图初始化编辑器,则说明您没有使用正确的代码。试试这个

$('.shorttext').ckeditor();
我们在中间传递了一些参数,但我不确定你的要求是什么。要传递它们,它看起来像这样
$('.shorttext').ckeditor({
    resize_enabled: false,
    toolbarCanCollapse: false, 
    etc...
});