I am using backbone and:
https://github.com/pragmaticly/smart-time-ago
When I load the page there is nothing displayed where the time ago is supposed to be(but backbone is working).
Here is my backbone view:
class Voice.Views.PostsIndex extends Backbone.View
template: JST['posts/index']
initialize: ->
@collection.on('reset', @render, this)
render: ->
$(@el).html(@template(posts: @collection)).timeago
this
templates/posts/index.jst.eco
<% for post in @posts.models: %>
<tbody id="postdata"><tr><td>
<center>
<% if post.get('content').length > 140: %>
<%=post.get('content').substring(0, 140)+"\t\t"%>
...<a href="show/<%= post.get('id') %>">see more</a>
<% else: %>
<%= post.get('content') %>
<% end %>
<br> </center>
<span class="green pull-left"><%= post.get('agrees') %> </span>
<span class="red pull-left"><%= post.get('disagrees') %> </span>
<span class="blue pull-left">0</span>
<span class="pull-right">
<time class="timeago" datetime="<%=post.get('created_at')%>">
</time>
</span>
</td></tr></tbody>
application.js
//= require jquery
//= require jquery_ujs
//= require timeago
//= require underscore
//= require backbone
//= require voice
//= require bootstrap.min
//= require_tree ../templates
//= require_tree ./models
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./routers
//= require_tree .
Is there anyway to get this to work? Thanks in advance
This is not a function call:
That just looks up the
timeagofunction on a jQuery object and, well, does nothing with it. You need to add parentheses (or an argument) to calltimeago:If you were supplying some arguments, you wouldn’t need the parentheses:
The presence of arguments is enough to tell CoffeeScript that you want to execute the function rather than get a reference to it.