0

The Visual Studio template has

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

in BundleConfig.cs and I want to add jquery-ui.min.js to the bundle. So I did

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

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

but now my I'm getting

Uncaught ReferenceError: jQuery is not defined

in my JS console. What should I have done if I wanted to add jquery-ui.min.js to the bundle, or do I need to add it separately?

1
  • Look at your rendered HTML. Is the order of the scripts correct? jquery.js will need to be listed before jquery-ui.js. Commented Feb 19, 2016 at 18:34

3 Answers 3

4

You need to only create 1 ScriptBundle("~/bundles/jquery"). You are creating 2 with the same name ("~/bundles/jquery") and the second one, which doesn't have the jQuery framework included, is overwriting the first

Like this:

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

Also of course make sure those paths are correct and that both jquery and jquery ui exist.

Sign up to request clarification or add additional context in comments.

Comments

0

You need to only create just one ScriptBundle("~/bundles/jquery").

same this:

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

Make sure those paths are correct and that both jquery and jquery ui exist.

Comments

-2

Can you reference using NuGet manager

enter image description here

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.