arrays - Ember Sort Models -


hi have array of models(images) model property of arraycontroller.

i want able sort the array such when click on image automatically moves predefined index. (e.g. when click item on array should move middle of array) , ui updated reflect new position.

here example of trying achieve: http://emberjs.jsbin.com/vesakafaca/1/edit?html,js,output

also since arraycontroller is/will depreciated v1.13 there alternative way of doing without using arraycontroller ?

here's updated emberjsbin of think you're looking -

http://emberjs.jsbin.com/qujihihivi/edit?html,js,output


  • arraycontroller vs. objectcontroller doesn't matter anymore, can use ember.controller.extend you'll see in updated bin.

  • i did sorting in model creating ember array model , tagging .sortby("index") onto it.

  • i updated templates new syntax, don't need {{bind-attr}} anymore , should use {{#each itemcollection |item|}} instead of {{#each itemcollection}}, makes easier read templates , provides consistent scope.

hope updated bin helpful!


Comments