RequireJS error in Admin

John Fu asked on December 11, 2014 11:17

Hi,

When I’m logged in to CMSDesk, I get a javascript error from RequireJS.
Mismatched anonymous define() module.

It is after including my vendor.js file, which is a compressed javascript file full of 3rd party libraries. Is there a way to get around this error?

Thanks.

Recent Answers


John Fu answered on December 11, 2014 12:10

For the record, angular is part of the vendor.js file. I had a dig around, and found that the config.js file used by Kentico's requireJS, HAS angular in it. Maybe that is causing the issue?

0 votesVote for this answer Mark as a Correct answer

John Fu answered on December 11, 2014 13:46

I noticed that even in the preview mode, there are a lot of JavaScripts that are injected into the page by kentico, e.g. Jquery and requirejs. Shouldn't the preview be a preview of what it'll look like in live? Do anyone know how to turn off these unwanted js includes? That is the cause of my headache.

Thanks

0 votesVote for this answer Mark as a Correct answer

Martin Danko answered on January 26, 2015 16:50

Hello John,

What is your environment setup... IIS, .NET, SQL and OS versions?

Is this a clean install of Kentico or upgraded website? Are you receiving this error also when you install e.g. a sample Corporate site?

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

Banjo Advertising answered on January 28, 2015 07:01 (last edited on January 28, 2015 07:05)

Hi Martin,

It's IIS 8, .NET 4.0, SQL Server 2012, Windows 8 server

Running Kentico 8.1.16, fresh install. I haven't tested the Corporate site, but I don't think theres any differences. Because in the Preview window, there are default javascripts loaded by Kentico.

I understand that the system is probably leveraging these scripts to make it work properly within the admin. But in my opinion, when you click the Preview mode, the user should be presented with a true representation of what they have built. i.e. Exactly what they will see when they go to live. But this isn't the case because all these administration site scripts are loaded.

So what I ended up doing is, in the MasterPage, I created a cms.js file that unloads the kentico admin scripts and used it with the following to get around it.

<script runat="server">
protected void Page_Load(Object sender, EventArgs e) {
if (CMS.PortalEngine.PortalContext.ViewMode== CMS.PortalEngine.ViewModeEnum.LiveSite)
{
    string jsBlock= String.Format("<script src='vendor.js'></script" + ">");
    if (!Page.ClientScript.IsStartupScriptRegistered("myJsInclude"))
        Page.ClientScript.RegisterStartupScript(typeof(string), "myJsInclude", jsBlock, false);
} else {
    CMS.Helpers.ScriptHelper.RegisterClientScriptInclude(this, this.GetType(), "cms.js", CMS.Helpers.URLHelper.ResolveUrl("~/CMSScripts/Custom/Crown/cms.js"), false);
}
</script>
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.