mina a.beigi
mina a.beigi

Reputation: 132

ckeditor.js:219 Uncaught TypeError: Cannot set property 'dir' of undefined

i installed logical Uploader for ckeditor in my project and it Was installed without problems. i have following controller :

 public class Default1Controller : Controller
{
    //
    // GET: /Default1/
    Context _db = new Context();
    [HttpGet]
    public ActionResult Index()
    {
        return View();
    }
    [HttpPost]
    public ActionResult Index(content model)
    {
        _db.tbl_Content.Add(model);
        _db.SaveChanges();
        return View();
    }
}

and my content model:

 public class content
{
    [Key]
    public int id { get;set; }
    public string text { get; set; }
}

my strongly typed Index View:

    @model ckeditor.Models.content
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>

@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>content</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.text)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.text)
            @Html.ValidationMessageFor(model => model.text)
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

<script src="~/Scripts/ckeditor/ckeditor.js"></script>
<script src="~/Scripts/ckeditor/adapters/jquery.js"></script>

<script>
    $(function () {

        $('#text').ckeditor();
    });
</script>
}

but i don't have ckeditor on my @html.TextAreaFor() what should i do? enter image description here

Upvotes: 2

Views: 7432

Answers (2)

Loyalar
Loyalar

Reputation: 2163

For others with this problem (since it still persists as of the newest version at this time), if you have self-hosted the CKEditor script in your solution (for example for a classic ASP.NET application) and you do not have all the localization files of the plugin in your CKEditor folder, that can cause this issue to happen.

We for example only had the en.js file in our /CKEditor/lang/ folder, and the bug occurred when a user that had both english and danish as his browser languages. CKEditor tried to automatically set the language of the editor to Danish, and tried to load the /CKEditor/lang/da.js file, which did not exist (which caused a 404 error). As seen in the original question here, the browser console shows a 404 error trying to load the /lang/fa.js language file, but to no avail. Adding the following to the config.js file fixed the problem for us:

config.language = 'en';

setting config.language ensures that the language of the editor is set to english instead of it being auto detected.

Upvotes: 0

Atzmon
Atzmon

Reputation: 1308

Try setting the CKEDITOR_BASEPATH variable:

<script>
    var CKEDITOR_BASEPATH = '/Scripts/ckeditor/';
</script>

See documentation here.

Upvotes: 3

Related Questions