[英]How to add or remove partial view Asp.net mvc with jquery?
I have a grid (Kendo grid), when occur edit function for any record of grid,I call a partial view with use of Jquery.Now i want after submit partial view, remove it from main view. 我有一个网格(Kendo网格),当网格的任何记录发生编辑功能时,我使用Jquery调用局部视图。现在我想要提交局部视图后,将其从主视图中删除。 My function for render partial view is : 我的渲染局部视图的功能是:
function ShowEditRecord(e) {
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
$.ajax(
{
url: '/Home/TestEdit/'+dataItem.Id.toString(),
contentType: 'application/html; charset=utf-8',
type: 'Get',
dataType: 'html'
})
.success(function(result)
{ $('#EditTestSection').html(result); })
My code of controller is : 我的控制器代码是:
public ActionResult TestEdit(Int64 Id)
{
var modelItem=getT().Where(a => a.Id == Id).FirstOrDefault();
return View (modelItem);
}
[HttpPost]
public ActionResult TestEdit(Models.Test Test)
{
base.Update(Test);
return View();
}
After occur edit function : 发生编辑功能后:
You can clear the markup from the partial view using empty()
: 您可以使用empty()
从局部视图中清除标记:
$('#EditTestSection').empty();
Which you would include as part of your submit function. 您将在提交功能中包含哪些内容。
jQuery的empty()函数删除了元素的所有子节点和文本,因此您可以使用类似的东西
$('#EditTestSection').empty();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.