2

I have problem with my website. I'm using Bootstrap 3.2 with Bootstrap Dialog instead of modals. When dialog opens, there's a scrollbar but closing it makes scrollbar disappear. I've read lots of topics but I haven't found working solution. Is there any way to solve this?

So, this is my dialog code:

$("a.removeClass").click(function() {

        var uid = $(this).attr('id');   

        BootstrapDialog.show({
            message: 'Czy na pewno chcesz usunąć tą klasę?',
            title: 'Usuwanie klasy',
            buttons: [{
                label: 'Usuń klasę',
                cssClass: 'btn-danger',
                action: function(dialog) {
                    $(location).attr('href','index.php?app=admin&section=classes&uid=' + uid + '&remove');
                }
            }]
        });
    });

It also doesnt work: How can I prevent body scrollbar and shifting when twitter bootstrap modal dialog is loaded?

Community
  • 1
  • 1
kuba12300
  • 21
  • 2
  • So... What's the question? – dowomenfart Mar 30 '15 at 17:35
  • Welcome to SO. In order for people to better help you, you should make sure your question is clearly stated. Also post the related code and let the community know what solutions you have tried. – crazymatt Mar 30 '15 at 18:35

1 Answers1

0

Add this to your CSS:

.modal {
  overflow-y: auto;
}
/* custom class to add space for scrollbar */
.modal-scrollbar {
    margin-right: 15px;
}

And this to your JS:

(function($) {

$(document)
    .on( 'hidden.bs.modal', '.modal', function() {
        $(document.body).removeClass( 'modal-scrollbar' );
    })
    .on( 'show.bs.modal', '.modal', function() {
        // Bootstrap's .modal-open class hides any scrollbar on the body,
        // so if there IS a scrollbar on the body at modal open time, then
        // add a right margin to take its place.
        if ( $(window).height() < $(document).height() ) {
            $(document.body).addClass( 'modal-scrollbar' );
        }
    });

})(window.jQuery);

Via- How can I prevent body scrollbar and shifting when twitter bootstrap modal dialog is loaded?

Community
  • 1
  • 1