CKEditor baseHref无法正常工作,编辑器在缩小/渲染后无法正常工作

Chr*_*Fin 4 .net javascript asp.net-mvc ckeditor asp.net-mvc-4

我正在使用ASP.NET MVC 4开发Web应用程序,我正在尝试使用CKEditor进行一些内容编辑.
在调试中,只要没有发生Bundeling或minification,一切正常,但是即使我设置了baseHref,CKEditor也会生成错误的URL:

CKEDITOR.replace('ckeditor',
{
    autoUpdateElement: true,
    baseHref: '@Url.Content("~/Scripts/ckeditor/")',
    filebrowserImageUploadUrl: '/Uploads/Upload'
});
Run Code Online (Sandbox Code Playgroud)

在调试中包括以下内容:

<script src="/Scripts/ckeditor/ckeditor.js"></script>
Run Code Online (Sandbox Code Playgroud)

在进行Bundeling/minifaction后,它只是:

<script src="/bundles/ckeditor?v=dLE-_JqB4vxXJ9idGep_8yUL8KfOwGhfYoEZAeIudoE1"></script>
Run Code Online (Sandbox Code Playgroud)

它试图加载以下JS文件:

http://DOMAIN.net/CONTROLLER/ACTION/config.js?t=D26D
Run Code Online (Sandbox Code Playgroud)

这应该是错的:

http://DOMAIN.net/Scripts/ckeditor/config.js?t=D26D
Run Code Online (Sandbox Code Playgroud)

有谁知道我做错了什么或如何解决这个问题?
或者我也可以禁用该捆绑的Bundeling/minification来避免这个问题.

小智 10

在包含ckeditor的js文件之前,尝试添加以下内容:

<script type="text/javascript">
    var CKEDITOR_BASEPATH = '@Url.Content("~/Scripts/ckeditor/")';
</script>
Run Code Online (Sandbox Code Playgroud)

更多信息:http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path

它也适用于ckeditor 4.x.


blu*_*uee 5

我有类似的问题,但发现这有效。将其包含在 cshtml 布局文件中。

<script>
  CKEDITOR.basePath = "@Url.Content("~/lib/ckeditor/")";
</script>
Run Code Online (Sandbox Code Playgroud)

或使用 JQuery

$(document).ready(function() { 
  CKEDITOR.basePath = "@Url.Content("~/lib/ckeditor/")"; 
});
Run Code Online (Sandbox Code Playgroud)