在JQueryMobile中使用autoInitializePage的示例 [英] Example using autoInitializePage in JQueryMobile
问题描述
我正在寻找一个简单的示例,该示例演示如何使用JQueryMobile呈现已在客户端动态组装的页面. $ .mobile.autoInitialize以前曾在几个版本上运行过,现在我们有了$ .mobile.autoInitializePage,但我似乎不知道该怎么做或找不到使用它的人的例子.
I am looking for a simple example showing how to use JQueryMobile to render a page that has been dynamically assembled on the client side. $.mobile.autoInitialize used to work a few versions ago, and now we have $.mobile.autoInitializePage but I can't seem to figure out how to do it or find any examples of people that are using it.
我最大的努力(现在开始工作-太早调用设置autoInitializePage了):
My best effort (THIS NOW WORKS - was calling setting autoInitializePage too early before):
<html>
<head>
<link class="jsbin" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" rel="stylesheet" type="text/css" />
<script class="jsbin" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script class="jsbin" src="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.js"></script>
<script>
$.mobile.autoInitializePage = false
</script>
</head>
<body>
</body>
<!-- coffeescript makes multiline strings easy -->
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
<script type='text/coffeescript'>
$('body').html "
<div data-role='page'>
<div data-role='header'><h1>Title</h1></div>
<div data-role='content'><p>Page content goes here.</p></div>
<div data-role='footer'><h4>Page Footer</h4></div>
</div>
";
$.mobile.initializePage();
</script>
</html>
结果在这里: http://jsbin.com/apocol/2 在这里遇到麻烦: http://jsbin.com/apocol/2/edit#html
Result here: http://jsbin.com/apocol/2 Mess around with it here: http://jsbin.com/apocol/2/edit#html
推荐答案
我不确定性能是否会受到影响或存在其他可能的问题,但是当我要强制进行彻底刷新时,我已将此方法成功地用于动态更新的页面.>
I am not sure of the performance impact or other possible gotchas but I have used this successfully with dynamically updated pages when I want to force a complete refresh.
$("#MyPage").page("destroy").page();
这篇关于在JQueryMobile中使用autoInitializePage的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!