如何显示模态而不是警报

时间:2016-04-23 16:36:45

标签: javascript twitter-bootstrap modal-dialog

这是我想在用户选择按钮时显示的模式弹出窗口,但他没有登录。

 <!--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">&times;</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.");
                }
            });
        }

但是,单击该按钮时不会显示任何内容。

1 个答案:

答案 0 :(得分:0)

替换:

            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.");
            }