【发布时间】:2019-08-15 12:36:03
【问题描述】:
我想在单击后禁用 asp=action 链接 我有一个 foreach 循环可以在我的视图中的表格中显示我的书 我在购物车中添加书籍的 asp-action 正在循环中,但我只想禁用已经在购物车中的书籍而不是所有书籍
<a asp-action="AcheterLivre" asp-Controller="Achat" asp-route-id="@item.Isbn" id="disabled" onclick="return myFunction(this);"> Ajouter
我用 jquery 尝试了一些东西,但效果不好
我试过了
<script>
function myFunction() {
$("#disabled").one("click", function () {
alert("this book is already in the cart");
});
}
我的课堂上有这个功能 它验证书籍是否在购物车中,也许我应该使用它?
public bool IsPresent(string isbn)
{
//rechercher si l'isbn correspond a un livre de la liste
AchatLivreViewModel livre = ListeElements.Find(element => element.Isbn == isbn);
if (livre != null)
{
return true;
}
else
{
return false;
}
}
【问题讨论】:
标签: asp.net-mvc