I'm new here and thanks everyone's help first.
Having searched a lot, I still cannot make it work: using jquery mobile, why call to a function the 2nd time will not apply the theme?
I tried using enhanceWithin(), listview("refresh"), trigger('create') on different elements but still no luck.
I know it is bad to paste whole piece of code here but actually it is extracted from a larger one with some minor modifications. It is almost minimum amount to work.
<head>
<!-- Include meta tag to ensure proper rendering and touch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Include jQuery Mobile stylesheets -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<!-- Include the jQuery library -->
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<!-- Include the jQuery Mobile library -->
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Welcome!</p>
<button id="mybutton" class="ui-btn ui-icon-refresh ui-btn-icon-left">refresh</button>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
<div id="navbar" data-role="navbar">
</div>
</div>
</div>
<script>
window.onload=mytest();
function mytest() {
uln = $("<ul></ul>");
uln.attr ("name","myname");
$('#navbar').append(uln);
li = $("<button></button>");
href = $("<a></a>");
href.attr ("href","#");
node = document.createTextNode("mytest");
href.append(node);
li.append(href);
li.listview().enhanceWithin();
li.listview().listview("refresh");
uln.append(li);
}
$(".ui-icon-refresh").click(function(){
mytest();
$('#navbar').trigger('create');
});
</script>
</body>
Great appreciate to point out any bad coding and more important why it doesn't work.
Thanks.
Aucun commentaire:
Enregistrer un commentaire