Bootstrap Modals keep adding padding-right to body after closed

后端 未结 30 1941
南方客
南方客 2020-12-12 12:36

I am using bootstrap and Parse framework to build a small webapp. But those Bootstrap modals keep adding padding-right to body after closed. How to solve this?

I tri

30条回答
  •  执笔经年
    2020-12-12 12:58

    My solution does not require any additional CSS.

    As pointed by @Orland, one event is still happening when the other starts. My solution is about starting the second event (showing the adminPanel modal) only when the first one is finished (hiding the loginModal modal).

    You can accomplish that by attaching a listener to the hidden.bs.modal event of your loginModal modal like below:

    $('#loginModal').on('hidden.bs.modal', function (event) {
        $('#adminPanel').modal('show');
    }
    

    And, when necessary, just hide the loginModal modal.

    $('#loginModal').modal('hide');
    

    Of couse you can implement your own logic inside the listener in order to decide to show or not the adminPanel modal.

    You can get more info about Bootstrap Modal Events here.

    Good luck.

提交回复
热议问题