C# JQuery bundle not loading?

I was having issues with my JQuery script not working in C# Visual Studio 2013

The _Layout.cshtml had the required JQuery bundle in it @Scripts.Render(“~/bundles/jquery”)  & BundleConfig.cs had  bundles.Add(new ScriptBundle(“~/bundles/jquery”).Include(“~/Scripts/jquery-{version}.js”));

So way the heck doesn’t my script work

Answer because I didn’t surround the script call line with:

@section scripts{
  <script src="~/Scripts/ifDeviceAndroidRemovePrintButton.js"></script>
}

All because I had this at the top of the view & it was being called before the JQuery bundle loaded, therefore it did not know about JQuery and where to find it.

Moving the call script line to the last loaded item of the view and surrounding it with @Section scripts did the trick.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s