[英]Edit item modal popup asp.net mvc
我尝试使用此示例: MVC 5 Edit Bootstrap Modal Popup我有Index
页面,我在该页面上发送onclickEdit(id)
我有Edit
页面,我的模态 html 放置在该页面上。
.js:
{
var id = $(elem).data('assigned-id');
alert("1");
$.ajax({
url: '/Course/Edit/id=' + id,
success: function (data) {
alert("2");
$('#modalWrapper').html(data);
$('#editModal').modal();
}
});
}
alert("1") 有效, alert("2") 无效。
controller:
public IActionResult Edit(Guid id)
{
return PartialView(_courses.Find(id));
}
我检查了,我进入Edit()
,它通过了,但我没有进入 ajax 成功 我应该改变什么? 非常感谢
看起来您在modal()
function 中缺少字符串输入'show'
。 通过添加它,它将使模态可见。
$('#editModal').modal('show');
引导文档: https://getbootstrap.com/docs/4.1/components/modal/#modalshow
$.ajax({
url: '/Course/Edit/id=' + id,
type: 'GET',
cache: false,
success: function (result) {
alert("2");
$('#modalWrapper').html(result);
$('#editModal').modal('show');
}
});
您是否在 Chrome 浏览器的开发控制台中收到任何错误? 按 F12 访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.