How I added default sorting in my Ember.js application
This is a ridiculously short post and kind of highlights how amazing Ember.js is for writing web applications without having to do a lot of boilerplate code. Let's get started.
The solution
diff --git a/app/controllers/shows.js b/app/controllers/shows.js
index b387bf5..94845aa 100644
--- a/app/controllers/shows.js
+++ b/app/controllers/shows.js
@@ -1,4 +1,6 @@
export default Ember.ArrayController.extend({
+ sortProperties: ['title'],
+ sortAscending: true,
modalId: null,
modalTitle: null,
modalEpisode: null,
diff --git a/app/controllers/shows.js b/app/controllers/shows.js
index b387bf5..94845aa 100644
--- a/app/controllers/shows.js
+++ b/app/controllers/shows.js
@@ -1,4 +1,6 @@
export default Ember.ArrayController.extend({
+ sortProperties: ['title'],
+ sortAscending: true,
modalId: null,
modalTitle: null,
modalEpisode: null,
Done.
Conclusion
Because of the hard work of the folks at Ember.js, I was able to leverage the code already available in the Ember.sortableMixin class just by supplying attributes in my controller.
When I first saw this online, I couldn't believe that I didn't have to do anything to get sorting done. Just one of the many nice things about working with Ember.
My (very simple) Ember.js application is available on Github here. Demo here.
Screenshot:
Author And Source
この問題について(How I added default sorting in my Ember.js application), 我々は、より多くの情報をここで見つけました https://qiita.com/kimagure/items/5e7d50250c716e766383著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .