X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/1c9098d6313e24c7fd873859c7e10b81452f4bec..d0cbddd54807e6e43f2ab75bd234ddc0beaa8d86:/project/static/js/views/panel_container.js?ds=sidebyside diff --git a/project/static/js/views/panel_container.js b/project/static/js/views/panel_container.js index 332e83a6..6dbddd98 100644 --- a/project/static/js/views/panel_container.js +++ b/project/static/js/views/panel_container.js @@ -10,22 +10,38 @@ var PanelContainerView = View.extend({ init: function(element, model, template) { this._super(element, model, template); - $('select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this)); + $('.panel-main-toolbar select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this)); + $('.panel-main-toolbar .refresh', this.element.get(0)) + .bind('click.panel-container-view', this.refreshButtonClicked.bind(this)) + .attr('disabled', 'disabled'); }, selectChanged: function(event) { var value = $('select', this.element.get(0)).val(); var klass = panels[value]; + if (this.contentView) { this.contentView.dispose(); this.contentView = null; } + + if( value != 'empty') { this.contentView = new klass($('.content-view', this.element.get(0)), this.model.contentModels[value], this); + $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null); + } + }, + + refreshButtonClicked: function(event) { + if (this.contentView) { + console.log('refreshButtonClicked'); + this.contentView.reload(); + } }, dispose: function() { - $('select', this.element.get(0)).unbind('change.panel-container-view'); + $('.panel-main-toolbar .refresh', this.element.get(0)).unbind('click.panel-container-view'); + $('.panel-main-toolbar select', this.element.get(0)).unbind('change.panel-container-view'); this._super(); } });