1 /*globals View render_template panels*/
3 var PanelContainerView = View.extend({
4 _className: 'PanelContainerView',
7 template: 'panel-container-view-template',
10 init: function(element, model, template) {
11 this._super(element, model, template);
13 $('.panel-main-toolbar select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this));
14 $('.panel-main-toolbar .refresh', this.element.get(0))
15 .bind('click.panel-container-view', this.refreshButtonClicked.bind(this))
16 .attr('disabled', 'disabled');
19 selectChanged: function(event) {
20 var value = $('select', this.element.get(0)).val();
21 var klass = panels[value];
23 if (this.contentView) {
24 this.contentView.dispose();
25 this.contentView = null;
28 if( value != 'empty') {
29 this.contentView = new klass($('.content-view',
30 this.element.get(0)), this.model.contentModels[value], this);
31 $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null);
35 refreshButtonClicked: function(event) {
36 if (this.contentView) {
37 console.log('refreshButtonClicked');
38 this.contentView.reload();
43 $('.panel-main-toolbar .refresh', this.element.get(0)).unbind('click.panel-container-view');
44 $('.panel-main-toolbar select', this.element.get(0)).unbind('change.panel-container-view');