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

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

Footer.html:

index.html的:

 
 

EVENT CALENDAR

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.

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

假设其余代码有效:

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

对我来说,我不得不使用回调函数,并将其添加到我的pageinit事件中:

 $(document).on('pageinit', function(event){ $("#footerDiv").load('_footer.html', function(){$(this).trigger("create")}); });