fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Uproszczenie implementacji wzorca observer.
[redakcja.git]
/
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
66683dd
..
c873574
100644
(file)
--- a/
project/static/js/views/panel_container.js
+++ b/
project/static/js/views/panel_container.js
@@
-1,12
+1,14
@@
-/*globals
Class
render_template panels*/
+/*globals
View
render_template panels*/
-var PanelContainerView =
Class
.extend({
+var PanelContainerView =
View
.extend({
element: null,
element: null,
+ model: null,
template: 'panel-container-view-template',
contentView: null,
template: 'panel-container-view-template',
contentView: null,
- init: function(element, template) {
+ init: function(element,
model,
template) {
this.element = $(element);
this.element = $(element);
+ this.model = model;
this.template = template || this.template;
this.element.html(render_template(this.template, {panels: panels}));
this.template = template || this.template;
this.element.html(render_template(this.template, {panels: panels}));
@@
-17,12
+19,17
@@
var PanelContainerView = Class.extend({
var view = panels[$('select', this.element.get(0)).val()];
var klass = view.klass;
console.log(view, klass);
var view = panels[$('select', this.element.get(0)).val()];
var klass = view.klass;
console.log(view, klass);
- this.contentView = new klass($('.content-view', this.element.get(0)));
+ 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);
},
dispose: function() {
$('select', this.element.get(0)).unbind('change.panel-container-view');
console.log(this.contentView);
},
dispose: function() {
$('select', this.element.get(0)).unbind('change.panel-container-view');
+ this._super();
}
});
}
});