I am used to MVC2... Where you simply add your links to scripts and your sources to the view and just call the jquery function and viola... You have working Jquery code. But I am unable to get my jqGrid tableToGrid function working. I am guessing cause I am not loading the jquery libraries in right at all or I am not running the scripts in the right place. Could you take a look at my code and see what could possible be wrong?
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>ShowAllEncounters</title>
<link href="@Url.Content("~/Content/jquery.jqGrid/ui.jqgrid.css")" rel="Stylesheet" type="text/css"/>
</head>
This would be the head... I previously had my scripts linked in there as well... But that didn't work... So I put outside of the tag... like so...
</html>
<script src="@Url.Content("~/Scripts/jquery.jqGrid.min.js")" type="text/javascript"/>
<script type="text/javascript">
$(document).ready(function () {
...});
Am I missing something? How does one go about scripting jquery in an MVC4 site?
I can't even get a freaking alert to show up!!!!!!!!!!!!!
@model IEnumerable<FocusedReadMissionsRedux.Models.TemplateModel>
<!DOCTYPE html>
<html>
<head>
<script src="@Url.Content("~/Scripts/jquery.jqGrid.min.js")" type="text/javascript"/>
<link href="@Url.Content("~/Content/jquery.jqGrid/ui.jqgrid.css")" rel="Stylesheet" type="text/css"/>
<script type="text/javascript">
$(document).ready(function () {
alert("what is going on");
});
</script>
<title>ShowAllEncounters</title>
</head>
UPDATE: It would seem as though I am having an issue with when the jquery libraries are being loaded. Which would definitely be a problem. I need a solid pattern for adding these scripts to a project?
In the "new" MVC4 templates, jquery scripts are added at the "bottom" of the _layout.cshtml via Bundles.
Move the @Scripts.Render("~/bundles/jquery") within your block of the _layout.cshtml.
I'm not sure why the template puts this script include at the end of the html file...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With