[英]How to display modal instead of alert
这是我要在用户选择按钮且未登录时显示的模式弹出窗口。
<!--You must be logged in-->
<div class="modal fade" id="must-be-logged-in" tabindex="-1" role="dialog" aria-labelledby="Log-In" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="Login">Delete Account</h4>
</div>
<div class="modal-body">
<form action="@Url.Action("Register","Home")" method="post">
<label for="confirm">Tour could not be added to Wishlist. Please make sure that you are logged in.</label>
<p class="text-center">
<button class="btn btn-template-main"><i class="fa fa-user-times"></i>Log-In</button>
</p>
</form>
</div>
</div>
</div>
</div>
<!--You must be logged in-->
从我的javascript函数中,我将其调用如下:
function addToWishlistFun(tourid) {
if (document.getElementById("wishlist" + tourid).value == "added")
{
$.post('@Url.Action("RemoveFromWishlist", "Home")', { id: tourid }, function (data) {
if (data) {
var elementid = "wishlist" + tourid;
document.getElementById(elementid).innerHTML = "Add to wishlist" + "<i class=\"fa fa-heart-o\"></i>";
document.getElementById(elementid).value = "notadded";
}
else {
//$("#testPopup").toggle();
document.getElementById("#must-be-logged-in")
// alert("Tour could not be removed from wishlist. Please make sure that you are logged in.");
}
});
}
但是,单击该按钮时,不会显示任何内容。
更换:
else {
//$("#testPopup").toggle();
document.getElementById("#must-be-logged-in")
// alert("Tour could not be removed from wishlist. Please make sure that you are logged in.");
}
对于:
else {
$("#must-be-logged-in").toggle();
// alert("Tour could not be removed from wishlist. Please make sure that you are logged in.");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.