I am working on a web site using jquery mobile. In a page with a list of links, I need to append a query string parameter to hyperlinks that indicates the page size (obtained via javascript). So, the link
/view/id:1
should become
/view/id:1?size={sizeInPixels}
The marked up list looks like this:
<li><a data-ajax="false" class="imagelink" href="/view/id:2840"><h2>text here</h2></a></li>
<li><a data-ajax="false" class="imagelink" href="/view/id:2841"><h2>text here</h2></a></li>
The javascript is:
$(document).on('pageinit', '[data-role="page"]', function() {
var newSize = $(window).height()*.8;
newSize = parseInt(newSize);
$("a.imagelink[href!='ignore']").each(function() {
this.href += '?size=' + newSize;
});
});
When the page is first accessed, the size parameter is not appended; if the page is refreshed it works fine.
How can I get the size parameter appended when a user first loads the page?