[英]Having trouble with Ruby(rails) timestamp and jQuery timeago plugin
我正在从带时间戳的Rails应用中传回一个对象。 我正在尝试使用jQuery采取它出现的格式,并将其解析为“ 5分钟前”,“一个小时前”等。
$.each(data, function(i, issue){
var created = $.timeago(issue.created_at.to_datetime);
...
当我触发导致此事件的事件时,出现以下错误:
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'timeago'
有没有办法使用timeago插件来执行此操作,还是应该尝试其他方法?
为什么不使用Rails内置方法?
<%= time_ago_in_words(issue.created_at) %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.