1

PhonegapでjQueryモバイルを使用しています。
#content anther html ファイルにロードする「マスターページ」index.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 にロードしてメニューを閉じることです。私が間違っていることは何ですか?

4

1 に答える 1