抱歉,如果措辞不正确,很难解释。基本上我有一个项目列表,它们旁边有一个指定的日期。如果它们超过 30 分钟,那么它们会变红。完美运行,但不是实时的。需要刷新才能看到该项目变红。
{{#each callback in App.callbackController}}
<tr>
<td align="center" {{bindAttr style="callback.urgent"}}>{{callback.formatted_time}}</td>
</tr>
{{/each}}
App.Callback = Ember.Object.extend({
date_time: null,
urgent: function()
{
current_time = new Date().getTime();
callback_time = new Date(this.get('date_time')).getTime();
if(((callback_time - current_time) / 1000 / 60 * -1) > 30)
{
return 'color: #FFF; font-weight: bold; background: #'+Helpers.colours.red;
} else {
return 'color: #FFF; font-weight: bold; background: #'+Helpers.colours.green;
}
}.property('date_time')
});
无论如何要不断刷新紧急值?