我目前正在使用 asp.net mvc 4,并且正在尝试将 fullcalendar 添加到我的项目中。完整日历可在此处找到: http ://arshaw.com/fullcalendar/
当我单击我的操作链接时,我的日历不会加载。我似乎无法找到为什么它不起作用。
这是代码:
CSHTML
@section JavaScript
{
<link href="@Url.Content("/Content/fullcalendar.css") " rel="stylesheet" type="text/css" />
<script type="text/javascript" src="@Url.Content("/Scripts/jquery-ui-1.8.11.min.js")"></script>
<script type="text/javascript" src="@Url.Content("/Scripts/fullcalendar.js")"></script>
@* <script type="text/javascript" src="@Url.Content("/Scripts/fullcalendar.min.js")"></script>*@
}
@{
ViewBag.Title = "Tijdregistratie";
}
<script type='text/javascript'>
$(document).ready(function () {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: 'prev',
center: 'title',
right: 'next'
},
editable: true,
events: "/TijdRegistratie/GetGeplandeTaken/"
});
});
</script>
<div id='calendar'>
</div>
控制器
private TijdRegistratieService.ITijdRegistratieService _tijdRegistratieClient;
public TijdRegistratieController()
{
_tijdRegistratieClient = new TijdRegistratieService.TijdRegistratieServiceClient();
}
public ActionResult TijdRegistratieOverzicht()
{
return View("TijdRegistratieOverzicht");
}
public JsonResult GetGeplandeTaken(double start, double end)
{
String beginDatum = ConvertFromUnixTimestamp(start).ToString();
String eindDatum = ConvertFromUnixTimestamp(end).ToString();
int psnID = (int)HttpContext.Session["userPSNID"];
var geplandeTaken = _tijdRegistratieClient.GetGeregistreerdeTaken(1, beginDatum, eindDatum);
var eventList = from e in geplandeTaken
select new
{
id = e.taakID,
title = e.BeginUur.Substring(0, e.BeginUur.Length - 3) + " - " + e.EindUur.Substring(0, e.EindUur.Length - 3),
start = string.Format("{0:u}", e.BeginDatum),
end = string.Format("{0:u}", e.EindDatum)
//allDay = false
};
var rows = eventList.ToArray();
return Json(rows, JsonRequestBehavior.AllowGet);
}
private static DateTime ConvertFromUnixTimestamp(double timestamp)
{
var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
return origin.AddSeconds(timestamp);
}
Layout.cshtml(每页自动加载)
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title</title>
<meta name="viewport" content="width=device-width" />
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="~/Content/autocomplete.css" type="text/css" media="all" />
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.css" />
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/i8n/jquery.mobile.datebox.i8n.en.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/latest/jquery.mobile.datebox.min.js"></script>
<script type="text/javascript" src="http://dev.jtsage.com/cdn/datebox/i8n/jquery.mobile.datebox.i8n.en.js"></script>
@RenderSection("JavaScript", required: false)
<script>
所以我目前想知道如何解决这个问题。这是我使用 JQuery 的第二个项目,如果我遗漏了一些明显的东西,请原谅我。
编辑:在 Firefox 中运行时,我在 firebug 中收到以下错误:fullCalendar 不是函数。