2013-02-01 2 views
1

누구나 아직 시도해 보시겠습니까? 나는 일하기가 힘들다.jQuery 모바일로 timeago 사용

나는 다음과 같은 두 (둘 중 하나)를 사용하여 내 템플릿의 머리를 초기화 시도 :

<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>

:

<script> 
$('div:jqmData(role="page")').live('pagebeforeshow',function(){ 
    jQuery("abbr.timeago").timeago(); 
}); 
</script> 

<script> 
jQuery(document).ready(function() { 
    jQuery("abbr.timeago").timeago(); 
}); 
</script> 

그런 다음 컨텐츠 섹션에서, 나는 그것을 구현하는 시도

문서가 제안하는 것과 마찬가지입니다.

비록 내가 July 17, 2008 만 볼 수 있으며 동적 시간은 변경되지 않습니다.

누구든지이 작업을 수행하는 방법을 알고 있습니까?

답변

1

그것은 당신이 예에서 볼 수 있듯이, 작동 : 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(); 
}); 
+0

감사합니다! 내가 뭘 잘못했는지 모르겠다. –

관련 문제