我正在使用带有 Phonegap 的 jQuery 手机。
我创建了一个“母版页” index.html 加载到#content anther html 文件。
我还有一个滑动菜单,我想用它来导航。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Computer World</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css"/>
<!--link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css" /-->
<link rel="stylesheet" href="css/styles.css"/>
<!--script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script-->
<!--script type="text/javascript" src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script-->
<script type="text/javascript" src="script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="script/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript">
function loadPage(page){
$('#content').load(page);
}
$(document).on('pageinit', function(){
console.log("pageinit");
loadPage('main.html');
});
</script>
</head>
<body>
<div data-role="page" id="home" data-theme="b">
<div id="header" data-role="header" data-theme="b">
<a id="bars-button" data-icon="bars" class="ui-btn-right" style="margin-top:10px;" href="#navpanel">Menu</a>
</div>
<div id="content" data-role="content">
</div>
<div data-role="panel" id="navpanel" data-theme="a" data-display="push" data-position="right">
<div data-role="controlgroup" data-corners="false">
<a href="Main.html" data-role="button">Main</a>
<a href="#navpanel" onclick="loadPage('business.html')" rel="external">Business</a>
<a href="numbers.html" data-role="button">Numbers</a>
<a href="money.html" data-role="button">Money</a>
<a href="people.html" data-role="button">People</a>
</div>
</div>
</div>
</body>
</html>
当我使用<a href="Main.html" data-role="button">Main</a>
它时,它会转到另一个页面
,但是当我使用时,<a href="#navpanel" onclick="loadPage('business.html')" rel="external">Business</a>
我得到了下一个例外:
Uncaught TypeError: Cannot read property 'options' of undefined
a
e.widget._create
(anonymous function)
e.Widget._createWidget
e.widget._createWidget
(anonymous function)
e.(anonymous function).(anonymous function)
(anonymous function)
b.extend.each
b.fn.b.each
e.fn.(anonymous function)
e.widget.enhance
(anonymous function)
e.widget.enhanceWithin
(anonymous function)
(anonymous function)
b.event.dispatch
v.handle
b.event.trigger
(anonymous function)
b.extend.each
b.fn.b.each
b.fn.extend.trigger
e.Widget._trigger
e.Widget._createWidget
e.widget._createWidget
(anonymous function)
e.(anonymous function).(anonymous function)
(anonymous function)
b.extend.each
b.fn.b.each
e.fn.(anonymous function)
r
e.mobile.changePage
e.mobile.gradeA.e.extend.initializePage
(anonymous function)
c
p.fireWith
b.extend.ready
我要做的是将外部文件内容加载到#content 并关闭菜单。我做错了什么?