ajax.Actionlink OnComplete 从未被调用
我正在使用 @Ajax.ActionLink 删除一条记录:
@Ajax.ActionLink("Delete","DeleteRun",new {RunId = run.RunId},
new AjaxOptions() { Confirm = "Are you sure you want to delete this entry?",
HttpMethod = "DELETE",
OnComplete = string.Format("DeleteRunInTable({0});",run.RunId)
})
生成以下链接:
<a data-ajax="true" data-ajax-complete="DeleteRunInTable(11);" data-ajax-confirm="Are you sure you want to delete this entry?" data-ajax-method="DELETE" href="/Runs/Delete/11">Delete</a>
删除工作正常,但 OnComplete javascript 函数“DeleteRunInTable”从未被调用(我在 javascript 中放置了一个断点)。有人知道为什么吗?
这是 javascript 函数(作为外部文件包含):
function DeleteRunInTable(RunId) {
$("tr[data-runid=" + RunId).remove();
}
我已经检查了 chrome 开发人员工具以确保脚本加载正常,而且确实如此。我还确保包含了 jquery 和 jquery unobtrusive。
I am using @Ajax.ActionLink to delete a record:
@Ajax.ActionLink("Delete","DeleteRun",new {RunId = run.RunId},
new AjaxOptions() { Confirm = "Are you sure you want to delete this entry?",
HttpMethod = "DELETE",
OnComplete = string.Format("DeleteRunInTable({0});",run.RunId)
})
Which produces the following link:
<a data-ajax="true" data-ajax-complete="DeleteRunInTable(11);" data-ajax-confirm="Are you sure you want to delete this entry?" data-ajax-method="DELETE" href="/Runs/Delete/11">Delete</a>
The delete is working perfectly but the OnComplete javascript function "DeleteRunInTable" is never called (i put a breakpoint in the javascript). Anyone know why?
Here is the javascript function (included as an external file):
function DeleteRunInTable(RunId) {
$("tr[data-runid=" + RunId).remove();
}
I've checked in chrome developer tools to make sure the script is loading ok and it is. I also made sure jquery and jquery unobtrusive were being included.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢我让它工作了。我稍微改变了这个函数:
不知道为什么它之前没有在断点处停止,但现在它工作正常。
Thanks i got it working. I changed the function a little:
Don't know why it wasn't stopping at the break point before but now its working fine.