0

This is my 1st time using mvc bundles & I'm having an issue with my jquery bundle. If I reference my jquery with the following, everything's fine:

<script src="~/Scripts/jquery-2.1.1.min.js"></script>

However, if I use this, I get the good ole "'jQuery' is undefined" error:

@Scripts.Render("~/bundles/plugins/jquery/js")

Here's my full code: My View:

<!-- /// Jquery plugins ////////  -->
 @Scripts.Render(~/bundles/base/jquery/js")
@Scripts.Render("~/bundles/plugins/jquery/js")

<!-- /// Animations ////////  -->
@Scripts.Render("~/bundles/animations/js")

<!-- /// Plugins ////////  -->
@Scripts.Render("~/bundles/plugins/js")

<!-- /// gMap ////////  -->
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
@Scripts.Render("~/bundles/gmap/js")

@Scripts.Render("~/bundles/twitter/js")

<!-- /// Custom JS ////////  -->
@Scripts.Render("~/bundles/custom/js")

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

And here's my BundleConfig:

public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/base/jquery/js").Include(
                    "~/Scripts/jquery-2.1.1.min.js"));

        bundles.Add(new ScriptBundle("~/bundles/plugins/jquery/js").Include(
                    "~/Scripts/viewport/jquery.viewport.js",
                    "~/Scripts/easing/jquery.easing.1.3.js",
                    "~/Scripts/simpleplaceholder/jquery.simpleplaceholder.js",
                    "~/Scripts/fitvids/jquery.fitvids.js"));

        bundles.Add(new ScriptBundle("~/bundles/animations/js").Include(
                    "~/Scripts/animations/animate.js"));

        bundles.Add(new ScriptBundle("~/bundles/plugins/js").Include(
                    "~/Scripts/superfish/hoverIntent.js",
                    "~/Scripts/superfish/superfish.js",
                    "~/Scripts/revolutionslider/js/jquery.themepunch.plugins.min.js",
                    "~/Scripts/revolutionslider/js/jquery.themepunch.revolution.min.js",
                    "~/Scripts/bxslider/jquery.bxslider.min.js",
                    "~/Scripts//magnificpopup/jquery.magnific-popup.min.js",
                    "~/Scripts/isotope/imagesloaded.pkgd.min.js",
                    "~/Scripts/isotope/isotope.pkgd.min.js",
                    "~/Scripts/parallax/jquery.parallax.min.js",
                    "~/Scripts/easypiechart/jquery.easypiechart.min.js",
                    "~/Scripts/itplayer/jquery.mb.YTPlayer.js",
                    "~/Scripts/easytabs/jquery.easytabs.min.js",
                    "~/Scripts/waypoints/waypoints.min.js",
                    "~/Scripts/jqueryvalidate/jquery.validate.min.js",
                    "~/Scripts/jqueryform/jquery.form.min.js"));

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

        bundles.Add(new ScriptBundle("~/bundles/twitter/js").Include(
                    "~/Scripts/twitter/twitterfetcher.js"));

        bundles.Add(new ScriptBundle("~/bundles/custom/js").Include(
                    "~/Scripts/plugins.js",
                    "~/Scripts/scripts.js"));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                    "~/Content/base.css",
                    //"~/Content/boxed.css",
                    "~/Content/elements.css",
                    "~/Content/grid.css",
                    "~/Content/layout.css"));

        bundles.Add(new StyleBundle("~/Content/fontawesome/css").Include("~/Content/fontawesome/font-awesome.min.css"));

        bundles.Add(new StyleBundle("~/Content/iconfont/css").Include("~/Content/icon-font-custom.css"));

        bundles.Add(new StyleBundle("~/Content/skins/css").Include("~/Content/skins/default.css"));

        bundles.Add(new StyleBundle("~/Content/plugins/css").Include(
                    "~/Scripts/revolutionslider/css/settings.css",
                    "~/Scripts/revolutionslider/css/custom.css",
                    "~/Scripts/bxslider/jquery.bxslider.css",
                    "~/Scripts/magnificpopup/magnific-popup.css",
                    "~/Scripts/animations/animate.min.css",
                    "~/Scripts/itplayer/css/YTPlayer.css"));
    }

Any idea what I'm missing?

Thanks

1
  • I experienced this issue when I ran the bundling on localhost. The issue was resolved after I changed including .min.js files to regular .js files in bundles. If your render statements and paths are correct and still getting the same issue, perhaps give it a try. Commented Mar 25, 2015 at 22:24

3 Answers 3

1

Change

    bundles.Add(new ScriptBundle("~/bundles/plugins/jquery/js").Include(
                "~/Scripts/viewport/jquery.viewport.js",
                "~/Scripts/easing/jquery.easing.1.3.js",
                "~/Scripts/simpleplaceholder/jquery.simpleplaceholder.js",
                "~/Scripts/fitvids/jquery.fitvids.js"));

To

        bundles.Add(new ScriptBundle("~/bundles/plugins/jquery/js").Include(
                    "~/Scripts/jquery-2.1.1.min.js",
                    "~/Scripts/viewport/jquery.viewport.js",
                    "~/Scripts/easing/jquery.easing.1.3.js",
                    "~/Scripts/simpleplaceholder/jquery.simpleplaceholder.js",
                "~/Scripts/fitvids/jquery.fitvids.js"));

Or... Add

@Scripts.Render("~/bundles/base/jquery/js")

Right above

@Scripts.Render("~/bundles/plugins/jquery/js")
Sign up to request clarification or add additional context in comments.

Comments

1

It is because you will not be referencing the jquery

lack this line in your code

@Scripts.Render("~/bundles/base/jquery/js")

Comments

0

I realized my problem. Bundles seem to ignore .min script files. I followed the example from here and it seemed to have worked

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.