This worked for me : http://jsfiddle.net/emBxx/2/
HTML:
<script type="text/javascript" src="js/main.js"></script>
...
<div data-role="page" data-theme="b">
<header></header>
<div data-role="content">
<div class="content-primary">
<br />
<ul data-role="listview" data-filter="true">
<li><a href="index.html">Some</a></li>
<li><a href="index.html">random</a></li>
<li><a href="index.html">searchable</a></li>
<li><a href="index.html">content</a></li>
<li><a href="index.html">(list!)</a></li>
</ul>
</div><!--/content-primary -->
</div>
<footer></footer>
</div><!-- page end-->
<script>
appendJQMHeader('Injected header !');
appendJQMFooter('—Injected ftr!', 'JQM 1.3.1Beta');
</script>
JS, in js/main.js:
function appendJQMHeader(pageTitle) {
$('header').replaceWith(
'<header data-role="header" data-theme="f">'+
'<h1>'+pageTitle+'</h1>'+
'<a href="index.html" data-transition="slide" data-rel="back" data-icon="home" data-iconpos="notext" data-ajax="true">Home</a>'+
'</header><!-- /header -->');
}
function appendJQMFooter(left, right) {
$('footer').replaceWith('<footer data-role="footer" data-theme="f" class="jqm-footer"><p>©'+left+'!</p><p class="jqm-version">—'+right+'</p></footer>');
}
Note: for JSfiddle, it require 'Framework & extension
> No wrap - in <head>
'
For stand alone version, it worked fine with html head calling js/main.js containing the JS. Then html body with appendJQMHeader()
& appendJQMFooter()
. See the fiddle :)