What I want to do is to have my navbar HTML markup in one place ( for easy editing). Right now my index.html body content looks like:
<div data-role="page" id="SomePage">
<div data-role="header">
<h1>This is Page 1</h1>
</div>
<div data-role="navbar"></div>
</div>
and am calling the my files in the header as such:
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript" language="javascript" src="app.js"></script>
in my app.js file is where I am trying to load the nav bar. I have tried it 2 ways
The first:
var NavBar = function() {
$('div[data-role="navbar"]').html('<ul>' +
'<li><a href="#SomePage" data-transition="fade" data-icon="none">By Brand</a></li>' +
'<li><a href="#AnotherPage" data-transition="fade" data-icon="none">By Flavor</a></li>' +
'<li><a href="#LastPage" data-transition="fade" data-icon="none">Zero Nicotine</a></li>' +
'</ul>');
}
$(document).ready(function() {
NavBar();
});
This results in the page getting the app to show my links, but they are stack like a normal ul without the list-style
The second way I tried it was:
var NavBar = function() {
$('div:jqmData[role="navbar"]').html('<ul>' +
'<li><a href="#SomePage" data-transition="fade" data-icon="none">By Brand</a></li>' +
'<li><a href="#AnotherPage" data-transition="fade" data-icon="none">By Flavor</a></li>' +
'<li><a href="#LastPage" data-transition="fade" data-icon="none">Zero Nicotine</a></li>' +
'</ul>');
}
$(document).ready(function() {
NavBar();
});
This results in not seeing the links at all.
How do I create a function to load the 'navbar' in one place and use the jQuery Mobile styling?