3

The jQuery Mobile popup dimensions are limited to having a 15px margin on the left an right sides, and a 30px margin on the top and bottom. If the content is too large for these constraints, then the popup grows longer (not wider), so that the whole page must be scrolled to view the popup content.

I need to change this behavior such that the popup dimensions never exceed the height of the window, and such that the content scrolls vertically within the popup.

It is possible to limit the size of the popup thusly:

$('#popup').on({
  popupbeforeposition: function() {
    var maxHeight = $(window).height() - 30
    $('#popup').css('max-height', maxHeight + 'px')
  }
})

...but the popup content is the same, passing the bottom of the popup and still forcing the user to scroll the page, rather than the content within the popup.

How do I allow the popup content to scroll vertically within the popup?

popup content goes past window bottom

Jacob Marble
  • 24,696
  • 18
  • 62
  • 76

1 Answers1

7

You should use:

$('#popup').css('overflow-y', 'scroll');    

Here's a working example: http://jsfiddle.net/Gajotres/mmRnq/

Final notes

If you want to find more about how to customize jQuery Mobile page and widgets then take a look at this article. It comes with a lot of working examples, including why is !important necessary for jQuery Mobile.

Lee Taylor
  • 6,091
  • 14
  • 26
  • 43
Gajotres
  • 57,163
  • 16
  • 99
  • 128
  • @Gajotres: How to do this _only_ when the popup is larger than the user's viewport? http://stackoverflow.com/questions/22894479/how-to-check-if-jqm-popup-fits-users-viewport – Mark Boulder Apr 06 '14 at 13:10