I am confused over a little problem i have with jquery in my project. The project is a MVC4 site in visual studio 11.
The problem is that jQuery is not included in the bundling, and it seems to been working before i updated to 1.7.2, but can't be sure.
I can see the comment of the jQuery file on top of the bundled file, but cant find any code of it. All other files seems to be included though (my own scripts and jquery ui files).
I have tried bundle filters and create my own bundle, but nothing seems to work.
I really would appreciate any help, as when the page load, all java scripts just crash because a function is not found. This does work if i just include the java script files normally.
Edit:
Global.asax:
protected void Application_Start()
{
BundleTable.Bundles.EnableDefaultBundles();
}
_Layout.cshtml:
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>
Update 1:
I added some code the the jQuery file, and the bundled file contained this at the top.
function Test(){ }
Then changed to this, and the code was not there this time.
(function Test(){ })
The wierd thing is that the other jQuery files, like the UI ones doesnt get removed, and they being the same way.
Edit: seems like this is intended
Update 2:
Tested some more and found out which file that breaks, if i include any of these files in my custom bundle, it breaks
- jquery.validate.js
- jquery.validate.unobtrusive.js
- jquery.unobtrusive-ajax.min.js
Before them i have these, and they work without any error
- jquery-1.7.2.min.js
- jquery-ui-1.8.19.min.js
- bootstrap.min.js
It is still wierd, if i include these file as normal in the script with <script src="~/Scripts/jquery.validate.js"></script>
they work as they should, without errors.
Though, if i bundle the working files, and then add the non-working one after as normally, they still breaks
_Layout.cshtml:
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/myBundle")"></script>
<script src="~/Scripts/jquery.validate.js"></script>
Global.asax:
var bundle = new Bundle("~/js", new JsMinify());
bundle.AddFile("~/Scripts/jquery-1.7.2.min.js");
bundle.AddFile("~/Scripts/jquery-ui-1.8.19.min.js");
bundle.AddFile("~/Scripts/bootstrap.min.js");
BundleTable.Bundles.Add(bundle);
Edit: seems like something is changed in the bundled jquery files, that makes the validate plugins to break
Work Around
I tried to add the old files, before the update, and it work! Managed to find out that it was the new jQuery UI 1.8.19 from NuGet that crashed.
I downloaded the jquery ui directly from their site, and used that one instead, and it worked!
So it seems that something in the jquery ui nuget version is changed that the bundling is picking up and changes/removes it, so it breaks..
which part to blame? jQuery UI NuGet packages or mvc4 bundling? And is there a solution to the bundling problem?