3

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?

Hao Kung
  • 28,040
  • 6
  • 84
  • 93
Scottie
  • 11,050
  • 19
  • 68
  • 109

2 Answers2

7

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

Hao Kung
  • 28,040
  • 6
  • 84
  • 93
1

If you change the bundle definition from:

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

to:

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

It will work like a harm.

So for debugging purpose jquery.jqGrid.src.js will be loaded while during running application in the release configuration jquery.jqGrid.min.js will be loaded.

denciaq
  • 21
  • 3