How can I hide my alert within a modal in Jquery?

1

What happens is that I have a Finalizar compra button that when giving click and not being logged, a modal appears with the alert message

  

"You should sign up before continuing with your purchase"

and I have another button in the navbar of carrito that pulls the same modal but without the alert message, my problem is that if I first give click to the button of carrito I do not get the message and that's fine but if I give click to the button of Finalizar compra I get the modal with the alert message and if I close the modal and I give click now to carrito I keep coming out the alert message and that is what I do not want.

My HTML of the alert is this:

<div class="modal signUpContent fade" id="ModalLogin" tabindex="-1" role="dialog">
<div class="modal-dialog ">
    <div class="modal-content">

        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button>
            <h3 class="modal-title-site text-center"> Ingresa a {{ store.name }} </h3>
        </div>
        <div class="modal-body">
            <div id="kapps_modal_login" class="alert alert-danger" style="display: none;" shopping_cart_url="{% url "store_shopping_cart" %}">
                <strong>¡ATENCIÓN!</strong> <p>Date de alta o crea una cuenta para proceder con la compra.</p>
            </div>
                  .
                  .
                  .

and my JQUERY is this:

    self.active_listener_kapps_alert = function(){
    $('#ModalLogin').on('shown.bs.modal', function (e) {
        var shopping_cart_url = $('#kapps_modal_login').attr('shopping_cart_url');
        if(window.has_active_kapps && shopping_cart_url == window.location.pathname ) {
            $('#kapps_modal_login').show();
        }
    });
};
    
asked by Rafael 26.07.2018 в 19:49
source

1 answer

2

Well nobody answered my question but I found the solution by modifying my java script.

 self.active_listener_kapps_alert = function(){
    $('#ModalLogin').on('shown.bs.modal', function (e) {
        var shopping_cart_url = $('#kapps_modal_login').attr('shopping_cart_url');
        if(window.has_active_kapps && shopping_cart_url == window.location.pathname ) {
            $('#kapps_modal_login').show().end();
        }
    });

    $('#ModalLogin').on('hidden.bs.modal', function (e) {
        window.has_active_kapps = false;
        $('#kapps_modal_login').hide();   
    });
};
    
answered by 27.07.2018 в 16:51