Not so many…


Home | Pages | Archives


C# JQuery bundle not loading?

March 18, 2015 1:40 pm

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.

Posted by Raymond Reid

Categories: .NET

Tags:

Leave a Reply



Mobile Site | Full Site


Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.