簡體   English   中英

Ruby(rails)時間戳和jQuery timeago插件遇到問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM