我正在做一个 Orchard 项目,我正试图让我的 ajax 代码在那里工作。
这是视图:
@model Ignite.Events.ViewModels.EventListPartViewModel
@{
Script.Require("jQuery");
Script.Include("EventList.js").AtLocation(Orchard.UI.Resources.ResourceLocation.Foot);
Script.Include("fullcalendar.js").AtLocation(Orchard.UI.Resources.ResourceLocation.Foot);
Script.Include("EventCalendar.js").AtLocation(Orchard.UI.Resources.ResourceLocation.Foot);
Script.Include("jquery.unobtrusive-ajax.js").AtLocation(Orchard.UI.Resources.ResourceLocation.Foot);
Style.Include("fullcalendar.css").AtLocation(Orchard.UI.Resources.ResourceLocation.Foot);
}
@using (Ajax.BeginForm("GetEventListItems", "Events", new { area="Ignite.Events", month = 4, year = 2013 }, new AjaxOptions { UpdateTargetId = "event-list", HttpMethod = "GET", InsertionMode = InsertionMode.Replace}, new { id = "ajaxForm" }))
{
@Html.AntiForgeryToken();
<input type="submit" value="Get Next" />
}
<table id="event-list" class="event-list">
@Html.Partial("_EventList", Model.Events)
</table>
<div id="calendar" class="clear"></div>
这是一个返回部分视图的控制器:
[ValidateAntiForgeryToken]
public PartialViewResult GetEventListItems(int? month, int? year)
{
if (month == null || year == null)
{
month = DateTime.Now.Month;
year = DateTime.Now.Year;
}
var result = _eventListDataService.GetEventListItems((int) month, (int) year);
return PartialView("_EventList", result);
}
我想知道为什么我总是只得到部分视图而不是完整的视图,其中呈现了部分视图。
谢谢,
雅库布