diff --git a/static/js/app/views/mix/mixListLayout.coffee b/static/js/app/views/mix/mixListLayout.coffee index 71adee2..85a23fd 100644 --- a/static/js/app/views/mix/mixListLayout.coffee +++ b/static/js/app/views/mix/mixListLayout.coffee @@ -17,10 +17,5 @@ define ['marionette', 'vent', 'views/widgets/mixTabHeaderView', 'views/mix/mixLi showMixList: (options)-> console.log("Layout: showoing mixlist") @bodyRegion.show(new MixListView(options)) - @tabChanged(options.order_by) - - tabChanged: (type) -> - $('#mix-tab li[id=li-' + type + ']', @el).addClass('active') - true MixListRegionView \ No newline at end of file diff --git a/static/js/app/views/mix/mixListLayout.js b/static/js/app/views/mix/mixListLayout.js index 1f186cb..a789233 100644 --- a/static/js/app/views/mix/mixListLayout.js +++ b/static/js/app/views/mix/mixListLayout.js @@ -30,13 +30,7 @@ MixListRegionView.prototype.showMixList = function(options) { console.log("Layout: showoing mixlist"); - this.bodyRegion.show(new MixListView(options)); - return this.tabChanged(options.order_by); - }; - - MixListRegionView.prototype.tabChanged = function(type) { - $('#mix-tab li[id=li-' + type + ']', this.el).addClass('active'); - return true; + return this.bodyRegion.show(new MixListView(options)); }; return MixListRegionView; diff --git a/static/js/app/views/widgets/mixTabHeaderView.coffee b/static/js/app/views/widgets/mixTabHeaderView.coffee index c5e5aca..4a397a0 100644 --- a/static/js/app/views/widgets/mixTabHeaderView.coffee +++ b/static/js/app/views/widgets/mixTabHeaderView.coffee @@ -4,4 +4,12 @@ define ['marionette', 'underscore', 'vent', 'text!/tpl/MixTabHeaderView'], class MixTabHeaderView extends Marionette.ItemView template: _.template(Template) + initialize: -> + @listenTo(vent, "mix:showlist", @tabChanged) + + tabChanged: (options) -> + $('#mix-tab li[id=li-' + options.order_by + ']', @el).addClass('active') + true + + MixTabHeaderView \ No newline at end of file diff --git a/static/js/app/views/widgets/mixTabHeaderView.js b/static/js/app/views/widgets/mixTabHeaderView.js index d356e99..9d8c86f 100644 --- a/static/js/app/views/widgets/mixTabHeaderView.js +++ b/static/js/app/views/widgets/mixTabHeaderView.js @@ -15,6 +15,15 @@ MixTabHeaderView.prototype.template = _.template(Template); + MixTabHeaderView.prototype.initialize = function() { + return this.listenTo(vent, "mix:showlist", this.tabChanged); + }; + + MixTabHeaderView.prototype.tabChanged = function(options) { + $('#mix-tab li[id=li-' + options.order_by + ']', this.el).addClass('active'); + return true; + }; + return MixTabHeaderView; })(Marionette.ItemView);