panel not working in all pages using JQuery Mobile

可紊 提交于 2019-11-29 08:43:40

If you want to access the same panel from any pages, you have to place panel div outside any data-role="page", and then you have to initialize it manually. This is called an external panel.

<body>
  <div data-role="panel" id="foo" data-theme="a">
    <!-- contents -->
  </div>

  <!-- pages here -->
</body>

Note that an external panel doesn't inherit theme automatically, thus, you need to add data-theme attribute to it.

The .enhanceWithin() function is to enhance all widgets inside the panel. They aren't auto-initialized, so they need to be initialized.

$(function () {
  $("[data-role=panel]").enhanceWithin().panel();
});

Place that code in head after JQM library.

Demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!