jQuery Mobile - 包含外部文件的页脚
我想创建一个共享页脚(例如 footer.html),可供 jQuery Mobile 应用程序中的所有页面使用。但是,我无法找到一种方法让 jQuery 在从外部文件加载 html 后刷新页脚导航栏中的样式。经过思考后将不胜感激。
页脚.html:
<div data-role="navbar" class="CSS" data-grid="d" id="footerNav">
<ul >
<li ><a href="#" id="a" data-icon="custom"><div>a</div></a></li>
<li ><a href="#" id="b" data-icon="custom"><div>b</div></a></li>
<li ><a href="#" id="c" data-icon="custom"><div>c</div></a></li>
<li ><a href="#" id="d" data-icon="custom"><div>d</div></a></li>
<li ><a href="#" id="e" data-icon="custom"><div>e</div></a></li>
</ul>
</div>
索引.html:
<div data-role="page" style="position: relative" data-theme="a" id="index">
<div data-role="header">
<div class="homebutton" onclick="location.href='default.html'">
</div>
<h1>
EVENT CALENDAR</h1>
</div>
<div data-role="content">
<p>
This is a single page boilerplate template that you can copy to build you first
jQuery Mobile page. Each link or form from here will pull a new page in via Ajax
to support the animated page transitions.</p>
</div>
<div data-role="footer" class="CSO" data-position="fixed" id="footerDiv">
</div>
<script>
$('#index').live('pageinit', function (event, ui) {
$('#footerDiv').load('Shared/Footer.html');
[Some code to refresh the footer so it gets redrawn by Jquery Mobile]
});
</script>
I would like to create a shared footer (e.g. footer.html) that can be used by all of the pages in my jQuery Mobile application. However, I cannot find a way to get jQuery to refresh the styles in the footer navbar after loading the html from the external file. After thoughts would be greatly appreciated.
Footer.html:
<div data-role="navbar" class="CSS" data-grid="d" id="footerNav">
<ul >
<li ><a href="#" id="a" data-icon="custom"><div>a</div></a></li>
<li ><a href="#" id="b" data-icon="custom"><div>b</div></a></li>
<li ><a href="#" id="c" data-icon="custom"><div>c</div></a></li>
<li ><a href="#" id="d" data-icon="custom"><div>d</div></a></li>
<li ><a href="#" id="e" data-icon="custom"><div>e</div></a></li>
</ul>
</div>
Index.html:
<div data-role="page" style="position: relative" data-theme="a" id="index">
<div data-role="header">
<div class="homebutton" onclick="location.href='default.html'">
</div>
<h1>
EVENT CALENDAR</h1>
</div>
<div data-role="content">
<p>
This is a single page boilerplate template that you can copy to build you first
jQuery Mobile page. Each link or form from here will pull a new page in via Ajax
to support the animated page transitions.</p>
</div>
<div data-role="footer" class="CSO" data-position="fixed" id="footerDiv">
</div>
<script>
$('#index').live('pageinit', function (event, ui) {
$('#footerDiv').load('Shared/Footer.html');
[Some code to refresh the footer so it gets redrawn by Jquery Mobile]
});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设其余代码有效:
Assuming that the rest of the code is valid:
对我来说,我必须使用回调函数,并将其添加到我的 pageinit 事件中:
for me, I had to use the callback function, and add it in my pageinit event :