2016-05-15 125 views
1

我安装了逻辑上传器ckeditor在我的项目中,它的安装没有问题。我有以下控制器:ckeditor.js:219 Uncaught TypeError:无法设置未定义的属性'dir'

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(); 
    } 
} 

和我的内容模型:

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

我的强类型的索引视图:

@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> 
} 

,但我没有在我的@html.TextAreaFor() CKEditor的又该我做? enter image description here

+0

看看控制台中的第一个错误 - 你的脚本的一个没有被发现(检查路径) –

回答

3

尝试将CKEDITOR_BASEPATH变量:

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

见文档here

+0

感谢我却用它之前,仍然有这个错误!什么是默认1? –

+0

根据您的屏幕截图,您的站点或mvc项目称为'Default1',因此'Scripts'文件夹的URL位于Default1下。我建议你直接在浏览器中导航到一个ckeditor文件,当你知道正确的基本路径时,相应地定义CKEDITOR_BASEPATH。 – Atzmon

+0

对不起,我没有注意到'Default1'是你的控制器的名字。设置应该是'var CKEDITOR_BASEPATH ='/ Scripts/ckeditor /';' – Atzmon

相关问题