ember.js - EmberJS - display models in reverse order or by date order -


i have simple ember app gets array of models so:

app.indexroute = ember.route.extend({   model: function() {     return this.store.find("swap");                                                                                                                        } }); 

i output them in view so:

{{#each model}}     output stuff here {{/each}} 

this works fine. have form lets people add new instances of model, , works fine , adds new record bottom.

however, i'd in reverse. have 2 options far can see:

  • output array in reverse, , when new 1 added, add top, not bottom
  • each model has createdat property date, order each model createdat attribute in descending order

i think second option makes more sense, i'm not sure how it.

currently have app.indexroute , have app.applicationcontroller i've added custom properties to. presume need add property or method data store , order createdat?

jack, need use sortascending , sortproperties

app.somecontroller = ember.arraycontroller.extend({     sortproperties: ['order'],     sortascending: true }); 

edit note if you're using number id column , want sort that, you'll need explicitly convert number:

/**  * explicitly forces model id viewed integer, allowing correct numeric     sorting  */ order: function() {     return parseint(this.get('id'), 10); }.property('id'), 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -