0
我試圖彈出局部視圖。但它不工作,也沒有觸及控制器方法。 這是我的代碼。彈出式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