CKEditor baseHref does not work and the editor does not work after minimization / bonding

I am developing a web application using ASP.NET MVC 4 and I am trying to use CKEditor for some content editing.
In debug mode, everything works fine until no binding or minimization occurs, but as soon as CKEditor generates the wrong URLs, even if I set baseHref:

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

The debugging includes the following:

 <script src="/Scripts/ckeditor/ckeditor.js"></script> 

And after picking / minifaction it is simple:

 <script src="/bundles/ckeditor?v=dLE-_JqB4vxXJ9idGep_8yUL8KfOwGhfYoEZAeIudoE1"></script> 

and he is trying to download the following js files:

 http://DOMAIN.net/CONTROLLER/ACTION/config.js?t=D26D 

What is not as it should be:

 http://DOMAIN.net/Scripts/ckeditor/config.js?t=D26D 

Does anyone know what I'm doing wrong or how to fix it?
As an alternative, I would also be fine with the ability to disable linking / minimization for this single package to avoid this problem.

+4
source share
4 answers

Try adding the following content before including the ckeditor js file:

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

Additional information: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path

And he will also work with ckeditor 4.x.

+10
source

I had a similar problem, but I found this to work. Include it in the cshtml layout file.

 <script> CKEDITOR.basePath = "@Url.Content("~/lib/ckeditor/")"; </script> 

or using jquery

 $(document).ready(function() { CKEDITOR.basePath = "@Url.Content("~/lib/ckeditor/")"; }); 
+4
source

I found that a similar approach to @bluee worked for me:

I put the following in a cshtml layout file:

  <script type="text/javascript">CKEDITOR_BASEPATH = "@Url.Content("~/Scripts/ckeditor/")";</script> @Scripts.Render("~/Scripts/ckeditor/ckeditor.js") 

The subtle difference is using CKEDITOR_BASEPATH, not CKEDITOR.basePath. This solves the problem "CKEDITOR not defined."

0
source

I met the same problem. In fact, the bundle system makes ckeditor difficult to load. Therefore, you can avoid this:

 @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/Script/CKEditor/ckeditor.js") @Scripts.Render("~/Script/CKEditor/adapters/jquery.js") 
0
source

All Articles