【发布时间】:2016-05-24 18:21:01
【问题描述】:
我正在尝试使用 asp.net mvc 4 + jquery 在特定路径中打开模式,代码如下:
卡片.cshtml
<div class="btn-group">
<button class="btn btn-primary openModal" data-path="/Client/Edit/@Model.ClientID">Editar</button>
<button class="btn btn-primary openModal" data-path="/Client/Products/@Model.ClientID">Products</button>
</div>
然后在modal.js中
$(document).on('click', '.openModal', function () {
var path = $(this).attr("data-path");
$("#modal").load(path, function () {
$("#modal").modal();
})
});
在客户端控制器中
public ActionResult Edit(long id = 0)
{
Client client = db.Clients.Find(id);
if (client == null)
{
return HttpNotFound();
}
return View(client);
}
public ActionResult Products(long clientID)
{
return View(db.Products.Where(p => p.ClientID == clientID).ToList());
}
Edit 操作有效,但 Products 操作无效(我放置了一个断点,但没有调用它)。怎么了?
【问题讨论】:
-
你检查响应了吗,有没有错误?
-
浏览器只是像“编辑”模式打开时一样“淡出”,但没有发生,控制器的“产品操作”没有被调用,但是在chrome上检查jquery代码的“路径”属性是正确的
标签: jquery twitter-bootstrap asp.net-mvc-4 bootstrap-modal