1

I have an MVC 5 application where I need jQuery UI. So I downloaded jQuery UI (Combined Library) version 1.10.4 from NuGet and just to make sure also updated jQuery to version 2.1.1. Next thing I did was to set up the bundles like so:

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

bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
            "~/Content/themes/base/jquery.ui.all.css"));

And finally render those in my _Layout.cshtml in the following order:

In the head-tag:

@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jquery")

At the bottom then:

@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")

(Even when I copy the bottom to the head-tag or vice versa - nothing would change)

Now I set up a partial view with the following script at the top of the page:

<script type="text/javascript">
    $(function () {
        $("#commentSection").accordion();
    });
</script>

After typing the "." in $("#commentSection").accordion(); intellisense won't give me any jQueryUI-Element to choose from. And even after starting the app nothing happens. I've tried rendering the scripts and styles at the top of the view, too but with no effect. The same code would work on an MVC 4 test-ap. But there jQuery UI is already included. And yes, I kept pressing the "build solution" menu-entry like crazy... :P

So what am I doing wrong? Thanks for helping out.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
FunkyPeanut
  • 1,152
  • 2
  • 9
  • 28
  • Use some browser debugger and check to see if your scripts are included on the page – jamesSampica Aug 02 '14 at 01:47
  • 1
    Do you also have `bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));` in your `BundleConfig.cs` file –  Aug 02 '14 at 01:47
  • 1
    @StephenMuecke Yes they are included. I will see if I can figure out whether the scripts are rendered via browser. Thanks for the tip. – FunkyPeanut Aug 02 '14 at 01:48
  • Is this only happening in your partial view? Does you partial view also include the scripts? Intellisense won't work if the scripts are not referenced (but the code should till work if the its rendered in a view which includes the scripts, i.e. _Layout) –  Aug 02 '14 at 01:55
  • @StephenMuecke I've tried that already. Both intelisense and code do not work on views that include _Layout either. – FunkyPeanut Aug 02 '14 at 01:58
  • @Shoe Just checked: jQuerryUI and the rest is included. It is listed right at the top of the DOM Explorer inside the body tag. – FunkyPeanut Aug 02 '14 at 01:59
  • @StephenMuecke No - I just checked again. The code works on pages that have _Layout.cshtml referenced. But unfortunately intellisense still does not work there and how can I get it to work inside my partial views? Thanks so far! – FunkyPeanut Aug 02 '14 at 02:06
  • The answers to this [SO question](http://stackoverflow.com/questions/11488208/intellisense-doesnt-work-for-js-in-vs2012) might help –  Aug 02 '14 at 03:00

0 Answers0