在使用Ember模型之前,将我的ArrayController与sortProperties和sortAscending进行排序就像预期的一样。最近我转向了Ember-Model,排序功能不再起作用了。
目前为止的代码:
App.Movie = Ember.Model.extend({
rating: Ember.attr(),
title: Ember.attr(),
watched: Ember.attr(),
year: Ember.attr(),
});
App.MoviesIndexController = Ember.ArrayController.extend({
sortProperties: null,
sortAscending: null,
actions: {
sortByAttribute: function (attr) {
if (this.get('sortProperties')) {
if (this.get('sortProperties')[0] === attr) {
this.toggleProperty('sortAscending');
} else {
this.set('sortProperties', [attr]);
}
} else {
this.set('sortProperties', [attr]);
this.set('sortAscending', true);
}
}
}
});
<table>
<thead>
<tr>
<th {{action "sortByAttribute" "year"}}>Year </th>
</tr>
</thead>
...
</table>有什么想法吗?
Thx
发布于 2013-11-23 15:17:37
在我看来,这是可行的,下面是一个jsbin示例
http://emberjs.jsbin.com/eKibapI/8/edit
https://stackoverflow.com/questions/20162930
复制相似问题