Browse Source

Fixed #2

There will be 2 scrollbar displayed when dialog is opened.

Fixed by adding css class 'modal-open' to document.body when dialog is opened, remove it after dialog has closed.
Dante 12 years ago
parent
commit
bbda166d1b
2 changed files with 10 additions and 0 deletions
  1. 5 0
      examples/assets/bootstrap-dialog/js/bootstrap-dialog.js
  2. 5 0
      js/bootstrap-dialog.js

+ 5 - 0
examples/assets/bootstrap-dialog/js/bootstrap-dialog.js

@@ -495,6 +495,7 @@ var BootstrapDialog = null;
             this.getModal().on('show.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 typeof dialog.options.onshow === 'function' && dialog.options.onshow(dialog);
+                dialog.showScrollBar(true);
             });
             this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
@@ -503,10 +504,14 @@ var BootstrapDialog = null;
             this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 dialog.isAutodestroy() && $(this).remove();
+                dialog.showScrollBar(false);
             });
 
             return this;
         },
+        showScrollBar: function(show){
+            $(document.body).toggleClass('modal-open', show);
+        },
         realize: function() {
             this.initModalStuff();
             this.getModal().addClass(BootstrapDialog.NAMESPACE)

+ 5 - 0
js/bootstrap-dialog.js

@@ -495,6 +495,7 @@ var BootstrapDialog = null;
             this.getModal().on('show.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 typeof dialog.options.onshow === 'function' && dialog.options.onshow(dialog);
+                dialog.showScrollBar(true);
             });
             this.getModal().on('hide.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
@@ -503,10 +504,14 @@ var BootstrapDialog = null;
             this.getModal().on('hidden.bs.modal', {dialog: this}, function(event) {
                 var dialog = event.data.dialog;
                 dialog.isAutodestroy() && $(this).remove();
+                dialog.showScrollBar(false);
             });
 
             return this;
         },
+        showScrollBar: function(show){
+            $(document.body).toggleClass('modal-open', show);
+        },
         realize: function() {
             this.initModalStuff();
             this.getModal().addClass(BootstrapDialog.NAMESPACE)