[英]Having trouble with Ruby(rails) timestamp and jQuery timeago plugin
I am passing an object back from my rails app with a timestamp. 我正在从带时间戳的Rails应用中传回一个对象。 I'm trying to use jQuery to take the format it comes in and parse it to something like "5 minutes ago" "an hour ago" etc.
我正在尝试使用jQuery采取它出现的格式,并将其解析为“ 5分钟前”,“一个小时前”等。
$.each(data, function(i, issue){
var created = $.timeago(issue.created_at.to_datetime);
...
When I trigger the event that causes this, I get the following error: 当我触发导致此事件的事件时,出现以下错误:
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'
Is there a way to do this with the timeago plugin or should I perhaps try a different method? 有没有办法使用timeago插件来执行此操作,还是应该尝试其他方法?
为什么不使用Rails内置方法?
<%= time_ago_in_words(issue.created_at) %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.