MVC4 bundling with TinyMCE

mortenstarck picture mortenstarck · Apr 10, 2013 · Viewed 7.4k times · Source

I have an problem using MVC4 Bundling together with TinyMCE. I get this error:

    GET http://localhost:54717/Admin/EditText//langs/da.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/lists/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/autolink/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//themes/advanced/editor_template.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/spellchecker/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/pagebreak/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/style/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/table/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/layer/editor_plugin.js 404 (Not Found) Site:1
    GET http://localhost:54717/Admin/EditText//plugins/save/editor_plugin.js 404 (Not Found)
Failed to load: http://localhost:54717/Admin/EditText//langs/da.js 

The code looks like this( In BundleConfig.cs)

bundles.Add(
      new ScriptBundle("~/Scripts/Site").Include(
        "~/Scripts/jquery-1.9.1.js",
        "~/Scripts/tinymce/tiny_mce.js",
         "~/Scripts/jquery-ui-1.10.1.js",
        "~/Scripts/jquery.ui.slider.js",
        "~/Scripts/oline.Base.js",
        "~/Scripts/Validate/Language/jquery.validationEngine-da.js",
        "~/Scripts/Validate/jquery.validationEngine.js",
        "~/Scripts/jquery.ui.effect-blind.js",
        "~/Scripts/jquery.placeholder.min.js"));

      BundleTable.EnableOptimizations = true; 

And in the layout:

@Scripts.Render("~/Scripts/Site")

But if i remove the the tiny_mce.js form the bundling and place it like so <script src="~/Scripts/tinymce/tiny_mce.js"></script> it works just fine. Is it because i need to override the automatic loading by tinymce and place do it manually?

Answer

Codeacula picture Codeacula · Apr 22, 2014

Before calling tinymce.init, do the following:

tinymce.baseURL = "@Url.Content("~/Scripts/tinymce")";

Or wherever your scripts are kept.

I had this same issue. This is my working final product

    <script>
    tinymce.baseURL = "@Url.Content("~/Scripts/tinymce")";

    // tinyMCE setup
    tinymce.init({
        selector: "textarea.rt-edit",
        browser_spellcheck: true,
        menubar: false,
        plugins: "paste,preview,code,textcolor,link",
        invalid_elements: "script",

        // Theme options - button# indicated the row# only
        toolbar1: "bold italic underline strikethrough subscript superscript link | fontselect fontsizeselect forecolor backcolor | justifyleft justifycenter justifyright cut copy paste pastetext pasteword| outdent indent | undo redo | code preview ",

    });
</script>