cms/app-client/app/components/playlist-component.js
changeset 215 82878d132784
parent 212 f2c6080a73aa
child 216 c174124d1849
--- a/cms/app-client/app/components/playlist-component.js	Wed Jun 29 10:54:13 2016 +0200
+++ b/cms/app-client/app/components/playlist-component.js	Fri Jul 01 22:15:35 2016 +0200
@@ -34,6 +34,18 @@
         return documents;
     }),
 
+    documentsLoaded: Ember.observer('documents', function() {
+        this.get('player').set('items', this.get('documents').map(function(document) {
+            return document.get('id');
+        }));
+
+        this.get('player').set('item', this.get('player').get('items')[0]);
+    }).on('init'),
+
+    init: function() {
+        this._super(...arguments);
+    },
+
     didRender: function() {
         this._super(...arguments);
         this.$().find('ul').height(Ember.$('.corpus-app-wrapper').outerHeight() - (Ember.$('.filter-component').outerHeight() + this.$().find('h2').outerHeight()));
@@ -42,10 +54,7 @@
     actions: {
 
         setItem: function(id) {
-            this.get('player').set('item', id);
-            this.get('player').set('items', this.get('documents').map(function(document) {
-                return document.get('id');
-            }));
+            this.get('player').trigger('reset', id);
         }
 
     }