Just a quick jQuery Mobile question.
I am working with ui-grid-a
(for the basic case of 50/50 split) and I can populate and render the grid without issue. However in some cases there are fewer items than the content size and I was curious if it was possible to have the grid not wrap the content, but instead fill the available space in the div.
I have tried a few different methods.
1) Basic configuration no modification- the ui-grid
seems to wrap the content inspection shows the height on the data-role=content
is much smaller than the page. Thus the grid is "filling" the content.
2) As a result I then worked to expand the content. Using some JS fiddle code (below) I was able to set a height to the content (and inspection confirmed this) however the grid remains only a fraction of the content area
jQuery code in .ready()
to adjust the content size to fill page
var screen = $.mobile.getScreenHeight();
var header = $(".ui-header").hasClass("ui-header-fixed") ? $(".ui-header").outerHeight() - 1 : $(".ui-header").outerHeight();
var footer = $(".ui-footer").hasClass("ui-footer-fixed") ? $(".ui-footer").outerHeight() - 1 : $(".ui-footer").outerHeight();
var contentCurrent = $(".ui-content").outerHeight() - $(".ui-content").height();
var content = screen - header - footer - contentCurrent;
$(".ui-content").height(content);
3) I tried binding this to the page load thinking that maybe the grid was calculated before the Javascript on ready fired. But no luck.
Any suggestions would be very welcome. I am not restricted to jQuery, I've tried many CSS options however those styles don't seem to help when using the custom jQuery Mobile UI (Content/Page)
Thank you in advance,
As requested a sample markup mirroring my own (I have some addition divs within this that are popups, but this represents the main content)
<div data-role="page" id="home" data-theme="b">
<div data-role="header">
<h1>Home</h1>
</div>
<div data-role="content">
<div class="ui-grid-a">
<div class="ui-block-a">
<a href="#" data-role="button">Test</a>
</div>
<div class="ui-block-b">
<a href="#" data-role="button">Test</a>
</div>
<div class="ui-block-a">
<a href="#" data-role="button">Test</a>
</div>
<div class="ui-block-b">
<a href="#" data-role="button">Test</a>
</div>
<div class="ui-block-a">
<a href="#" data-role="button">Test</a>
</div>
<div class="ui-block-b">
<a href="#" data-role="button">Test</a>
</div>
</div>
</div>
</div>