我有一个带有OnClick的表,它工作得很好。
<tr onclick="location.href = '@Url.Action("Index", new { id = item.CaseNumber, dp = item.DocumentPath, dt = item.DocumentType, sc = Model.SearchCriteria, rds = Model.ReturnDataSel })'">
但我想在它从Url.Action获取数据时显示一个微调器。所以我有jquery:
$("#res_table").click(function () {
var x = document.getElementById("spin_id");
x.style.display = "block";
如何使两者同时发挥作用?我知道我可以使用.ajax函数进行get调用,但我不知道如何引用html中的数据,即(id,dp,dt,sc,rds(
为什么不将它们合并到一个事件中?
<tr data-url="@(Url.Action("Index", new { id = item.CaseNumber, dp = item.DocumentPath, dt = item.DocumentType, sc = Model.SearchCriteria, rds = Model.ReturnDataSel }))">
然后:
$("tr").click(function () {
//Gets the URL from the data attribute
var url = $(this).data("url");
//Gets the spinner element
var x = document.getElementById("spin_id");
//Shows spinner element
x.style.display = "block";
//Redirects to URL
window.location.href = url ;
});