ember.js - Updating loaded models with JS -


to explain exact use-case: have news-model 'created_at' field. displaying dates arraycontroller works fine , expected. want now, converting these dates fuzzy times http://pragmaticly.github.io/smart-time-ago/ (or http://timeago.yarp.com/). problem here is, need call $('.timeago').timeago('refresh'); once timestamps loaded , displayed. seems work fine long navigate within ember-app. when refresh site plugin somehow can't convert it. suppose command doesn't called @ right time app. doing in following 2 ways right now: in view:

didinsertelement: function(){     $('body').timeago('refresh'); } 

and in controller:

updatefuzzytime: function(){     $('body').timeago('refresh'); }.observes('content') 

when in either place settimeout() command set 1000ms work.

so how can ember perform command when model loaded , displayed on refresh? (in project had similar issue , there used rerender() command did work, in use-case can not that)

edit: post here well. plugin looks @ datetime-attribute of time element. hbs code looks this:

<time class="timeago" {{bindattr datetime="date"}}>{{date}}</time> 

and suppose reason why hooks don't work because though dom rendered suppose ember hasn't updated attribute yet.

try calling in afterrender callback. executes after else.

init: function() {   this._super();   ember.run.scheduleonce('afterrender', this, 'updatefuzzytime'); }  updatefuzzytime: function() {   $('body').timeago('refresh'); } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -