Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to have jqueryUI dialog scrollbar start at the top, when content is longer than height?

I'm using a jquery UI dialog to have users accept a Terms & Conditions popup where the content is too long to fit in the popup's height. So a scrollbar appears when the dialog pops up, but it opens with the scrollbar at the bottom.

This doesn't seem to be possible through the dialog options.

Anyone know of a way to get the dialog to open with the scrollbar at the top?

like image 655
devjeff Avatar asked Mar 15 '12 18:03

devjeff


1 Answers

Like commented above you might have an element at the bottom of the dialog's content that initially receives focus, which causes the scroll bar to scroll to that element when the dialog opens. You can try the workaround in the comment, which should work if the problem is indeed caused by a focus issue. Alternatively, you can manually scroll the dialog's content to the top. You can accomplish this by specifying an open callback and scrolling the dialog's content to the top position in there, like so:

    $("#dialog").dialog({
        open: function () {
            $(this).scrollTop(0);
        }
    });
like image 149
Bojin Li Avatar answered Oct 20 '22 06:10

Bojin Li