X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9490c431ea46a6c3d9f1d348a5b525c0bd3b6359..ad481d9335cb91f56adfffda3999284f37d37942:/project/static/js/views/panel_container.js diff --git a/project/static/js/views/panel_container.js b/project/static/js/views/panel_container.js index c8735744..332e83a6 100644 --- a/project/static/js/views/panel_container.js +++ b/project/static/js/views/panel_container.js @@ -1,30 +1,27 @@ /*globals View render_template panels*/ var PanelContainerView = View.extend({ + _className: 'PanelContainerView', element: null, model: null, template: 'panel-container-view-template', contentView: null, init: function(element, model, template) { - this.element = $(element); - this.model = model; - this.template = template || this.template; - - this.element.html(render_template(this.template, {panels: panels})); + this._super(element, model, template); + $('select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this)); }, selectChanged: function(event) { - var view = panels[$('select', this.element.get(0)).val()]; - var klass = view.klass; - console.log(view, klass); + var value = $('select', this.element.get(0)).val(); + var klass = panels[value]; if (this.contentView) { this.contentView.dispose(); this.contentView = null; } - this.contentView = new klass($('.content-view', this.element.get(0)), this.model); - console.log(this.contentView); + this.contentView = new klass($('.content-view', + this.element.get(0)), this.model.contentModels[value], this); }, dispose: function() {