7

jQuery Mobileアプリケーションのすべてのページで使用できる共有フッター(例:footer.html)を作成したいと思います。ただし、外部ファイルからhtmlを読み込んだ後、jQueryでフッターナビゲーションバーのスタイルを更新する方法が見つかりません。考えていただければ幸いです。

Footer.html:

<div data-role="navbar" class="CSS" data-grid="d" id="footerNav">
    <ul >
        <li ><a href="#" id="a" data-icon="custom"><div>a</div></a></li>
        <li ><a href="#" id="b" data-icon="custom"><div>b</div></a></li>
        <li ><a href="#" id="c" data-icon="custom"><div>c</div></a></li>
        <li ><a href="#" id="d" data-icon="custom"><div>d</div></a></li>
        <li ><a href="#" id="e" data-icon="custom"><div>e</div></a></li>
    </ul>
</div>

Index.html:

<div data-role="page" style="position: relative" data-theme="a" id="index">
    <div data-role="header">
        <div class="homebutton" onclick="location.href='default.html'">
            &nbsp;</div>
        <h1>
            EVENT CALENDAR</h1>
    </div>
    <div data-role="content">
        <p>
            This is a single page boilerplate template that you can copy to build you first
            jQuery Mobile page. Each link or form from here will pull a new page in via Ajax
            to support the animated page transitions.</p>
    </div>

    <div data-role="footer" class="CSO" data-position="fixed" id="footerDiv">

    </div>

    <script>
    $('#index').live('pageinit', function (event, ui) {
         $('#footerDiv').load('Shared/Footer.html');
         [Some code to refresh the footer so it gets redrawn by Jquery Mobile]  
    });
    </script>   
4

2 に答える 2

8

コードの残りの部分が有効であると仮定します。

$('#footerDiv').load('Shared/Footer.html').trigger("create");
于 2011-11-17T03:45:54.367 に答える
2

私にとっては、コールバック関数を使用して、pageinit イベントに追加する必要がありました。

$(document).on('pageinit', function(event){
  $("#footerDiv").load('_footer.html', function(){$(this).trigger("create")});
});
于 2013-02-08T11:17:05.283 に答える