[英]Keep navbar on all pages with jQuery Mobile
I'm currently creating phonegap app using jquery mobile framework. 我目前正在使用jquery移动框架创建phonegap应用程序。
I have multiple pages, like this : 我有多个页面,像这样:
I want to have the navbar on every page, and keep it without duplicate it on every page (home, settings...) and I don't know why I can't do that (like include header.html ? or set navbar in global layout ?). 我想在每个页面上都有导航栏,并且在每个页面上保留它而不重复它(主页,设置......)我不知道为什么我不能这样做(比如包括header.html?或设置navbar在全球布局?)。 I browse in my app using link between pages
我使用页面之间的链接浏览我的应用程序
<a href="home.html" data-transition="slide">Home</a>
How can I do for keep my navbar ? 如何保留我的导航栏?
Thanks, 谢谢,
Try this post, it appends a common footer to all the pages form a common html file. 试试这篇文章,它会在所有页面上添加一个公共页脚,形成一个通用的html文件。
$('[data-role=page]').live('pageshow', function (event, ui) {
$("#" + event.target.id).find("[data-role=footer]").load("footer.html", function(){
$("#" + event.target.id).find("[data-role=navbar]").navbar()
});
});
For more info refer this post - Jquery Mobile Same Footer on Different Pages 有关更多信息,请参阅此文章 - 不同页面上的Jquery Mobile Same Footer
You must have the navbar element repeated in each data-role="page"
. 您必须在每个
data-role="page"
重复使用navbar元素。 like this Js Fiddle Work Out 喜欢这个Js Fiddle Work Out
or as suggested by dhaval, insert it on every page via ajax: but you don't gain much except if you have many tabs 或者按照dhaval的建议,通过ajax在每个页面上插入它:但除非有很多标签,否则你不会获得太多收益
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.