我试图弹出局部视图。但它不工作,也没有触及控制器方法。 这是我的代码。弹出式MVC 4局部视图
脚本: -
$(document).ready(function() {
$.ajaxSetup({ cache: false });
$("#cusCreate").live("click", function (e) {
e.preventDefault();
debugger;
var url = $(this).attr('href');
$("#dialog-edit").dialog({
type:"GET",
title: 'Add Customert',
autoOpen: false,
resizable: false,
height: 355,
width: 400,
show: { effect: 'drop', direction: "up" },
modal: true,
draggable: true,
open: function (event, ui) {
alert(url);
$(this).load(url);
},
close: function (event, ui) {
$(this).dialog('close');
}
});
$("#dialog-edit").dialog('open');
return false;
});
});
</script>
查看:
@Html.ActionLink("Create New", "Create", "Customer", null, new { @id = "cusCreate" })
控制器:
[HttpGet]
public ActionResult Create(int? id)
{
db.customers = null;
if (Request.IsAjaxRequest())
{
return PartialView("_Create", db.customers);
}
else
{
return View(db.customers);
}
// return View();
}
局部视图认为这是一个noraml一个...
remove'e.preventDefault();' – Amit
你会得到所需URL的警报吗? –
url可以进入警戒状态 – user2710638