【发布时间】:2014-02-17 05:21:45
【问题描述】:
您好,我正在按照此示例在多个页面中创建面板。它在 jquery mobile 1.3.2 中完美运行
HTML
<div data-role="page" id="p1">
<!-- header -->
<div data-role="header"> <a href="#mypanel" data-role="button" data-inline="true" data-icon="grid" data-iconpos="notext"></a>
<h1>Header</h1>
</div>
<!-- content -->
<div data-role="content">
<h1>contents</h1>
<a data-role="button" href="#p2">Page 2</a>
</div>
<!-- footer -->
<div data-role="footer">
<h1>Footer</h1>
</div>
</div>
<!-- page -->
<div data-role="page" id="p2">
<!-- header -->
<div data-role="header"> <a href="#mypanel" data-role="button" data-inline="true" data-icon="grid" data-iconpos="notext"></a>
<h1>Header</h1>
</div>
<!-- content -->
<div data-role="content">
<h1>contents</h1>
<a data-role="button" href="#p1">Page 1</a>
<a data-role="button" href="#p3">Page 3</a>
</div>
<!-- footer -->
<div data-role="footer">
<h1>Footer</h1>
</div>
</div>
<!-- page -->
<div data-role="page" id="p3">
<!-- header -->
<div data-role="header"> <a href="#mypanel" data-role="button" data-inline="true" data-icon="grid" data-iconpos="notext"></a>
<h1>Header</h1>
</div>
<!-- content -->
<div data-role="content">
<h1>contents</h1>
<a data-role="button" href="#p2">Page 2</a>
</div>
<!-- footer -->
<div data-role="footer">
<h1>Footer</h1>
</div>
</div>
JAVASCRIPT
var panel = '<div data-role="panel" id="mypanel" data-position="right" data-display="push"><h1>Panel</h1><p>stuff</p></div>';
$(document).on('pagebeforecreate', '[data-role=page]', function () {
if ($(this).find('[data-role=panel]').length === 0) {
$('[data-role=header]').before(panel);
}
$(document).on('pagebeforeshow', '[data-role=page]', function () {
$(this).trigger('pagecreate');
});
});
当我在 jquery mobile 1.4.1 中使用此示例时,它无法正常工作。面板最初只能工作,但是当我转到下一页时,面板无法正常工作?如何解决这个问题
【问题讨论】:
标签: jquery jquery-mobile panel