66683dd249cb9bf68f6bbc6c394ba9da9df91d12
[redakcja.git] / project / static / js / views / panel_container.js
1 /*globals Class render_template panels*/
2
3 var PanelContainerView = Class.extend({
4   element: null,
5   template: 'panel-container-view-template',
6   contentView: null,
7   
8   init: function(element, template) {
9     this.element = $(element);
10     this.template = template || this.template;
11     
12     this.element.html(render_template(this.template, {panels: panels}));
13     $('select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this));
14   },
15   
16   selectChanged: function(event) {
17     var view = panels[$('select', this.element.get(0)).val()];
18     var klass = view.klass;
19     console.log(view, klass);
20     this.contentView = new klass($('.content-view', this.element.get(0)));
21     console.log(this.contentView);
22   },
23   
24   dispose: function() {
25     $('select', this.element.get(0)).unbind('change.panel-container-view');
26   }
27 });
28