diff --git a/assets/js/components/library.js b/assets/js/components/library.js index c8c9bdd..854b54a 100644 --- a/assets/js/components/library.js +++ b/assets/js/components/library.js @@ -46,7 +46,7 @@ can.Component.extend({ } }, - ' showPanel': function(el, ev, data) { + ' switchPanel': function(el, ev, data) { this.scope.attr('currentDepth', data); } } diff --git a/assets/js/components/panel-albums.js b/assets/js/components/panel-albums.js index fd4b06e..336db9e 100644 --- a/assets/js/components/panel-albums.js +++ b/assets/js/components/panel-albums.js @@ -4,13 +4,6 @@ can.Component.extend({ template: can.view('views/panels/albums.mustache'), - init: function() { - var self = this; - Album.findAll({ artist: this.scope.artist }, function(data) { - self.scope.attr('items', data); - }); - }, - scope: { depth: "@", artist: "@", @@ -24,9 +17,19 @@ can.Component.extend({ } }, + events: { + init: function() { + var self = this; + Album.findAll({ artist: this.scope.artist }, function(data) { + self.scope.attr('items', data); + self.element.trigger('switchPanel', self.scope.depth); + }); + } + }, + helpers: { link: function(item) { - return can.route.link(item.name, { + return can.route.link(item.title, { type: 'library', show: 'songs', artist: item.artist, diff --git a/assets/js/components/panel-artists.js b/assets/js/components/panel-artists.js index 93ed99e..d1076c5 100644 --- a/assets/js/components/panel-artists.js +++ b/assets/js/components/panel-artists.js @@ -4,19 +4,20 @@ can.Component.extend({ template: can.view('views/panels/artists.mustache'), - init: function() { - var self = this; - Artist.findAll({}, function(data) { - console.log(data); - self.scope.attr('items', data); - self._control.element.trigger('showPanel', self.scope.depth); - }); - }, - scope: { depth: "@" }, + events: { + init: function() { + var self = this; + Artist.findAll({}, function(data) { + self.scope.attr('items', data); + self.element.trigger('switchPanel', self.scope.depth); + }); + } + }, + helpers: { link: function(item) { return can.route.link(item.name, { diff --git a/public/views/panels/albums.mustache b/public/views/panels/albums.mustache index 7014a63..c92b921 100644 --- a/public/views/panels/albums.mustache +++ b/public/views/panels/albums.mustache @@ -4,7 +4,7 @@