Close modals with jquery

Asked

Viewed 47 times

-1

I have a modal where the user can select a signature plan with the button

<button type="button" class="button-assign" data-bind="widgetLocaleText:'subscribeButton'"></button>

this opens a second modal where he can sign or return

<button type="button" id="btn-voltar" class="btns-return" data-bind="widgetLocaleText: 'btnReturn'"></button>

I would like the moment this second modal opens the first one to be hidden and only appear if the user clicks back, but it does not disappear and is in the background. I don’t use bootstrap or other framework. Follow the modal code

modalConfirmation: function() {
      $(".btn-assinar").on("click", function() {
        var my_popup = $("#modal-confirmation").popup();
        my_popup.open();
      });
    },

    modalCancel: function() {
      $(".btn-assinar").on("click", function() {
        var my_popup = $("#modal-upgrade").popup("show");
        my_popup.hide();
      });
    },

    cancelClub: function() {
      $(".btns-voltar").click(function() {
        $("#modal-upgrade").open();
      }); 
    }

  • Are you using a framework to use the mode? Like bootstrap?

  • I am not using bootstrap or other framework

  • 1

    Hello, Welcome to stackoverflow, I would suggest you take a look at tour to understand how the platform works and How to create a Minimum, Complete and Verifiable example and after that, edit your question including your code so the community can help you.

1 answer

0

You can put a data-Ismiss="modal" on the button that opens your second modal, this should solve your first problem, now you can put an action on the back button to open your first modal again.

$("#btn-voltar").click(function() {
   $('#id-primeiro-modal').modal('show');
});

For this to work you need to add an id to your first modal.

  • The first modal disappears when the second opens, but I could not make it open again

Browser other questions tagged

You are not signed in. Login or sign up in order to post.