Skip to content

Instantly share code, notes, and snippets.

@kwikwag
Created August 31, 2012 04:27
Show Gist options
  • Save kwikwag/3549061 to your computer and use it in GitHub Desktop.
Save kwikwag/3549061 to your computer and use it in GitHub Desktop.
for JQM bug: dynamic listview creation in a multipage doc fails if page has no '.ui-page' class
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<style type="text/css">
</style>
<script type="text/javascript">
function make_bugs() {
$('#container').html(
'<ul data-role="listview">' +
'<li><a href="#1">1</a></li>' +
'<li><a href="#2">2</a></li>' +
'<li><a href="#3">3</a></li>' +
'</ul>'
).trigger('create');
$.mobile.changePage('#page-2');
}
function workaround() {
$('#page-2').addClass('ui-page');
make_bugs();
}
</script>
<title>JQM</title>
</head>
<body>
<div id="page-1" data-role="page">
<div data-role="content">
<button onclick="make_bugs();">Make bugs</button>
<button onclick="workaround();">Workaround</button>
</div>
</div>
<div id="page-2" data-role="page">
<div data-role="content">
<div id="container">Go to page 1!</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment