Getting jquery to work with MVC4
It's not happening. I tried linking the scripts normally in _Layout.cshtml
with <script src='@Content.Url("..., installing Web Optimization and using
bundles, and putting @Scripts.Render() in the head/body/bottom of
_Layout.cshtml and before the <script> tag on the relevant page. What am I
missing?
Directory structure
Views
Shared
Js
jquery-1.10.2.js
jquery.color-2.1.2.min.js
BundleConfig.cs
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Views/Shared/Js/jquery-{version}.js",
"~/Views/Shared/Js/jquery.color-{version}.js")
);
}
Global.asax.cs
protected void Application_Start()
{
// blah, etc, then:
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
_Layout.cshtml
@Scripts.Render("~/bundles/jquery");
I can run the actual javascript/jquery code on JsFiddle, so the validity
of what I've written there isn't the problem.
No comments:
Post a Comment