jQuery Mobile 动态内容插入
好的,有人能帮我弄清楚为什么下面代码中的“test”li 不可见吗?我检查了 live dom,元素似乎正在处理:
<!DOCTYPE HTML>
<html>
<head>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script>
$(document).ready(function(){
$('<div data-role="content" class="content"><ul data-role="listview" data-inset="true"><li><a href="#im?at=animals">test</a></li></ul></div>').appendTo("#home").page();
$.mobile.changePage("#home", {transition: "none"});
});
</script>
</head>
<body>
<div id="home" data-role="page">
</div>
</body>
</html>
提前致谢。
Ok, would someone help me figure out why the "test" li in the following code isn't visible? I inspected the live dom and the elements do seem to be getting processed:
<!DOCTYPE HTML>
<html>
<head>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script>
$(document).ready(function(){
$('<div data-role="content" class="content"><ul data-role="listview" data-inset="true"><li><a href="#im?at=animals">test</a></li></ul></div>').appendTo("#home").page();
$.mobile.changePage("#home", {transition: "none"});
});
</script>
</head>
<body>
<div id="home" data-role="page">
</div>
</body>
</html>
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对changePage 的调用不起作用,因为默认情况下您只有一个可见/活动的页面。
您可以通过触发 create 事件来强制活动页面更新。
The call to changePage doesn't work because you only have a single page which is visible/active by default.
You can force the active page to update by triggering the create event.
下面的元素将
display
属性设置为none
并且隐藏了其同级元素:CSS 规则:
The element below has
display
property set tonone
and it hides its siblings:The CSS rule: