5

I use bootbox.js to make modal but when the modal fadeIn and the content is too long, the scrollbar goes at the level of the bottom button. I need the scrollbar stay on top when modal appear

enter image description here

Siguza
  • 21,155
  • 6
  • 52
  • 89
Thomas Mairé
  • 516
  • 4
  • 16
  • Show your code for showing bootbox. – Manwal Dec 24 '14 at 11:26
  • `var bootboxAffiche = function(p_titre, p_contenu){ bootbox.dialog({ title : p_titre, message : p_contenu, buttons:{ success: { label : 'Fermer', className: "btn-primary" } } }); }` – Thomas Mairé Dec 24 '14 at 13:08

2 Answers2

5

I've solved adding .off("shown.bs.modal"); after the bootbox.dialog.

bootbox.dialog({ ... }).off("shown.bs.modal");
Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129
Thomas Mairé
  • 516
  • 4
  • 16
  • Works great. Makes you wonder why this wasn't built into bootbox. – Ectropy Nov 15 '16 at 19:06
  • This is discussed in [issue #260](https://github.com/makeusabrew/bootbox/issues/260) and is caused by auto-focusing the primary button in the `shown` event. – Emile Bergeron Feb 14 '17 at 20:18
0

You can set the scrollTop with jQuery in you callback.

 bootbox.alert("Hello world!", function() {
      $('body').scrollTop(0);
    });
giannisf
  • 2,479
  • 1
  • 17
  • 29