我开发MVC应用程序和使用剃刀语法。
在这种应用中,我给评论设施。
我添加了一个局部视图,从数据库加载评论/记录。
在下面的图片中,我们可以看到这就是所谓的运行时间为员工索引视图的评论框。
现在,我们可以看到评论框,我打电话给在运行时,这部分观点,但问题是,我可以只在第一个记录该按钮不会在所有的工作第一个记录后添加评论......
什么缺什么? 是否有独立的过程,当我们调用任何局部视图运行时间,并在行动上呢?
见PIC ...
下面是代码....
@model PagedList.IPagedList<CRMEntities.Customer>
<link href="../../Content/Paging.css" rel="stylesheet" type="text/css" />
<link href="../../Content/EventEntity.css" rel="stylesheet" type="text/css" />
<script src="<%=Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")%>" type="text/javascript"></script>
<div id="ListBox">
<div id="ListHeader">
All customers(@Model.TotalItemCount)
</div>
@foreach (var item in Model)
{
<div id="ListContent">
<span class="ContentTitleField">@Html.ActionLink(item.Name, "Details", new { id = item.Id }, new { @style="color:#1A6690;" })</span>
@if (item.Owner != null)
{
<span class="ContentSecondaryField">@Html.ActionLink(item.Owner.FullName, "Details", "Employee", new { id = item.OwnerId }, new { @style = "color:#1A6690;" })</span>
}
<span class="ContentSecondaryField">@Html.DisplayFor(modelItem => item.Address)</span>
<span id="flagMenus">
@Html.Action("ShowFlag", "Flagging", new { entityId=item.Id, entityType="Customer"})
</span>
@if (item.Opportunities.Count > 0)
{
<span class="FlagOpportunity">@Html.ActionLink("opportunities(" + item.Opportunities.Count + ")", "Index", "Opportunity", new { custid = item.Id }, new { @style = "color:#fff;" })</span>
}
<div style="float:right;">
@Html.Action("SetRate", "Rating", new { entityId = item.Id, rating = item.Rating, entityname = "Customer" })
</div>
<div id="subscribeStatus" style="float:right;">
@Html.Action("ShowSubscribedStatus", "Subscribing", new { entityId = item.Id, entityType = "Customer" })
</div>
<div class="ListLinks">
<span class="ListEditLinks">
<span style="float:left;">@Html.ActionLink("edit", "Edit", new { id = item.Id })</span>
<span class="LinkSeparator"></span>
</span>
<span class="ListAddLinks">
<span style="float:left;">@Html.ActionLink("+opportunity", "Create", "Opportunity", new { custid = item.Id }, null)</span>
<span class="LinkSeparator"></span>
<span>@Ajax.ActionLink("+Comment", null, null, null, new { id = item.Id, @class = "addremark" })</span>
</span>
<div class="RemarkBox"></div>
</div>
<span class="CommentAdd">
</span>
<div class="CommentBlock">
</div>
<span>@Ajax.ActionLink("Add Comment", null, null, null, new { id = item.Id, @class = "addremark" })</span>
</div>
}
<div class="PagingBox">
@Html.Action("CreateLinks", "Pager", new { hasPreviousPage = Model.HasPreviousPage, hasNextPage = Model.HasNextPage, pageNumber = Model.PageNumber, pageCount = Model.PageCount })
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$('.RemarkBox').hide();
$('a.addremark').click(function () {
var url="@Html.Raw(Url.Action("ShowCommentBox", "Comment", new { Id = "idValue", EntityType = "Customer" }))";
url=url.replace("idValue",event.target.id);
$('.RemarkBox').load(url);
$(this).closest('div').find('div.RemarkBox').slideToggle(300);
return false;
});
$("a.pagenumber").click(function () {
var page = 0;
page = parseInt($(this).attr("id"));
$.ajax({
url: '@Url.Action("GetPagedCustomers")',
data: { "page": page },
success: function (data) { $("#customerlist").html(data); }
});
return false;
});
});
</script>