jQuery Mobile - 包含外部文件的页脚

标签 jquery dynamic mobile footer navbar

我想创建一个共享页脚(例如 footer.html),可供 jQuery Mobile 应用程序中的所有页面使用。但是,我无法找到一种方法让 jQuery 在从外部文件加载 html 后刷新页脚导航栏中的样式。经过思考后,我们将不胜感激。

页脚.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>

索引.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>   

最佳答案

假设其余代码有效:

$('#footerDiv').load('Shared/Footer.html').trigger("create");

关于jQuery Mobile - 包含外部文件的页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7974630/

相关文章:

javascript - 悬停时对图像和标签的 JQuery 效果

javascript - jQuery无限滚动缺少CSS背景加载量页面

dynamic - 为什么在 Rust 中使用动态错误而不是枚举很常见?使用编译时变体不好/不可能吗?

javascript - 单击按钮动态加载 DIV 的最简单方法?

javascript - 管道值 : Ajax + JQuery

javascript - 在输入和输出中添加逗号

actionscript-3 - AS3 圆角文本字段

asp.net - Orchard CMS 支持移动渲染吗?

android - 移动设备上的背景颜色明显变亮,有什么解决办法吗?

iphone - 为移动设备开发网站的最佳方式是什么?