简体   繁体   English

如何在Pageshow中隐藏和显示页眉和页脚工具栏

[英]How to Hide and Show Header and Footer Toolbar on Pageshow

im working with jquery mobile in my project and i implement a header and footer toolbar. 我在我的项目中使用jQuery mobile,我实现了页眉和页脚工具栏。

what i try to do is: 我想做的是:

always when i open a page, i want that the toolbars are hidden, and only when i click 1 time on the touchscreen i want to open them. 总是在我打开页面时,我希望工具栏是隐藏的,并且只有当我在触摸屏上单击1次时,我才想打开它们。

I have a script from a friend of mine and it works, 我有一个朋友的脚本,它可以工作,

but i have to do a double click on the touchscreen to open them... 但我必须在触摸屏上双击才能打开它们...

exists anyway to do this only with 1 click? 仍然存在,只有1次点击才能做到这一点?

Note: i have in my project several data-role="pages" 注意:我的项目中有几个data-role="pages"

my code: 我的代码:

HTML5: HTML5:

 <div data-role="header" data-theme="a" data-position="fixed" data-id="footer" data-fullscreen="true" class="hidden">TESTE</div>

<div data-role="footer" data-theme="a" data-position="fixed" data-id="footer2" data-fullscreen="true" class="hidden">TESTE</div>    

Script: 脚本:

  function enableHeaderFooter() {
    $(document).off("touchend", enableHeaderFooter);
    $("header, footer").removeClass("hidden");
  }
  $(document).on("touchend", enableHeaderFooter);

CSS: CSS:

.hidden{display:none}

give the header and footer CSS classes that contain the declaration "display: none", and use an javascript touch event handler bound to window to show them by removing that class. 提供包含声明“ display:none”的页眉和页脚CSS类,并使用绑定到window的javascript touch事件处理程序通过删除该类来显示它们。 Also note that data-role="header" is a bit silly, since html has a element for this. 另请注意,data-role =“ header”有点愚蠢,因为html具有用于此的元素。 Secondarily, note that you've given both id=footer which is guaranteed to cause problems. 其次,请注意,你给这两个id=footer这是保证会导致问题。

<header class="hidden" ...>...</header>
...
<footer class="hidden" ...>...</footer>

+ +

<script>
  function enableHeaderFooter() {
    $(document).off("touchend", enableHeaderFooter);
    $("header, footer").removeClass("hidden");
  }
  $(document).on("touchend", enableHeaderFooter);
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM