Search code examples
htmlasp.net-mvc-4asp.net-optimizationbundles

Why isn't my Scripts.RenderSection working for jqGrid?


I am using Visual Studio 2012 and MVC 4, and in my _Layout.cshtml, I have the following:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/jqueryui")
        @Scripts.Render("~/bundles/jqgrid")

        @RenderSection("head", required: false)
    </head>
    <body>
        @RenderBody()

        @RenderSection("scripts", required: false)
    </body>
</html>

and in the BundleConfig.cs I have

public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
            "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqgrid").Include(
            "~/Scripts/jquery.jqGrid.min.js"));
    }
}

I've triple checked and my scripts folder does indeed contain jquery.jqGrid.min.js, but it's not being included.

My Html head looks like:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <link href="/Viper/Content/css" rel="stylesheet"/>

    <script src="/Viper/Scripts/jquery-1.8.1.js"></script>

    <script src="/Viper/Scripts/jquery-ui-1.8.23.js"></script>

</head>

Any ideas why this is not being added?


Solution

  • The default behavior when debug=true is to ignore *.min.js(this is something we are looking at fixing).

    For now, the easiest thing to do is would be to rename your file to be jquery.jqGrid.js