サーバー モデルの percentFree 属性に応じて、a のクラス<tr>
をどちらか#warning
に設定しようとしています。#success
これは私のハンドルバーのテンプレートです:
<script type="text/x-handlebars" data-template-name="dashboard">
<h1>Virtual Image Overview</h1>
<table class="table table-hover">
<thead>
<tr>
<th>Machine Name</th>
<th>Drive</th>
<th>Total Size</th>
<th>Used Space</th>
<th>% free</th>
</tr>
</thead>
<tbody>
{{#each controller}}
<tr {{bindAttr class="status"}}>
<td>{{name}}</td>
<td>{{drive}}</td>
<td>{{totalSize}}</td>
<td>{{usedSpace}}</td>
<td>{{percentFree}}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>
そして、これは私のモデルです:
Dashboard.Server = DS.Model.extend({
name: DS.attr('string'),
drive: DS.attr('string'),
totalSize: DS.attr('number'),
usedSpace: DS.attr('number'),
percentFree: DS.attr('number'),
status: "",
setStatus: function() {
if(this.percentFree <= 0.50) {
this.status = "warning";
} else {
this.status = "success";
}
}
});
のクラスが<tr>
実際に更新されることはありませんが。これを行うためのより効率的な(正しい)方法はありますか?
私も試しstatus: this.setStatus()
てみました
setStatus: function() {
if(this.percentFree <= 0.50) {
return "warning";
} else {
return "success";
}
}
運が悪いと