有人试过了吗?我有一段艰难的时间让它工作。
我尝试在我的模板头部使用以下两个(一个或另一个)初始化它:
<script>
$('div:jqmData(role="page")').live('pagebeforeshow',function(){
jQuery("abbr.timeago").timeago();
});
</script>
<script>
jQuery(document).ready(function() {
jQuery("abbr.timeago").timeago();
});
</script>然后在内容部分,我尝试用以下方法实现它:
<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>
正如很久以前的文档所建议的那样。
虽然我只看到July 17, 2008,没有动态的时间变化。
有人知道怎么做吗?
发布于 2013-02-02 03:54:15
它可以工作,正如您在下面的示例中所看到的:http://jsfiddle.net/Gajotres/KXHBj/
HTML :
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" id="index">
<div data-theme="a" data-role="header">
<h3>
First Page
</h3>
<a href="#second" class="ui-btn-right">Next</a>
</div>
<div data-role="content">
<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>
</div>
<div data-theme="a" data-role="footer" data-position="fixed">
</div>
</div>
</body>
</html> JS :
$(document).on('pagebeforeshow', '#index', function(){
$(".timeago").timeago();
});https://stackoverflow.com/questions/14652496
复制相似问题