bootbox icon indicating copy to clipboard operation
bootbox copied to clipboard

scroll to top on alert

Open frafu opened this issue 13 years ago • 6 comments

Hi!

When I open a bootbox.alert window and the document is higher than the browser viewport, the document scrolls always to the top of the page. Is there a way to avoid this behaviour?

The same problem is also described here: http://stackoverflow.com/questions/12575222/bootbox-js-is-scrolling-the-window-up

regards franz

frafu avatar Jul 18 '13 11:07 frafu

Hi,

If you scroll down to the examples section on http://bootboxjs.com/ do these suffer the same issue? If the examples are fine then it must be code related; anything in your browser's console?

If you could let me know OS / browser etc if the problem persists that would be great :)

EDIT: my memory's failing me; preventing the event on the button / link / whatever which triggers the dialog is up to the developer; are you sure you're doing this correctly?

makeusabrew avatar Jul 18 '13 11:07 makeusabrew

The examples are working fine. But it does now work in my environment :-( So, it seems there is a problem in my code.

Thank you!

frafu avatar Jul 18 '13 11:07 frafu

Happy to try and help if you can paste me any console errors :). Are you calling e.preventDefault() inside the handler which then invokes bootbox?

makeusabrew avatar Jul 18 '13 11:07 makeusabrew

That was the problem! :-)

Thank you!

frafu avatar Jul 18 '13 12:07 frafu

I solve this problem. this is the solution: change the code of bootstrap.js,change the function:Modal.prototype.show: var scrollTop=$(window).scrollTop(); that.$element.addClass('in').attr('aria-hidden', false).focus() $(window).scrollTop(scrollTop);

alexmango avatar Jun 18 '14 09:06 alexmango

$('.modal').animate({scrollTop:0}, 500, 'swing');

IsaacBruno avatar May 28 '15 17:05 IsaacBruno