[#212,views][s]: refactor views and tutorial so that no render call in initialize and view element can be passed in externally (fixes #212).
This commit is contained in:
@@ -156,6 +156,7 @@ var graph = new recline.View.Graph({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$el.append(graph.el);
|
$el.append(graph.el);
|
||||||
|
graph.render();
|
||||||
graph.redraw();
|
graph.redraw();
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
@@ -174,6 +175,7 @@ var graph = new recline.View.Graph({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$el.append(graph.el);
|
$el.append(graph.el);
|
||||||
|
graph.render();
|
||||||
graph.redraw();
|
graph.redraw();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -213,7 +215,7 @@ var map = new recline.View.Map({
|
|||||||
model: dataset
|
model: dataset
|
||||||
});
|
});
|
||||||
$el.append(map.el);
|
$el.append(map.el);
|
||||||
map.redraw();
|
map.render();
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
<div id="mymap"> </div>
|
<div id="mymap"> </div>
|
||||||
|
|||||||
@@ -21,18 +21,16 @@ this.recline.View = this.recline.View || {};
|
|||||||
// NB: should *not* provide an el argument to the view but must let the view
|
// NB: should *not* provide an el argument to the view but must let the view
|
||||||
// generate the element itself (you can then append view.el to the DOM.
|
// generate the element itself (you can then append view.el to the DOM.
|
||||||
my.Graph = Backbone.View.extend({
|
my.Graph = Backbone.View.extend({
|
||||||
tagName: "div",
|
|
||||||
className: "recline-graph",
|
|
||||||
|
|
||||||
template: ' \
|
template: ' \
|
||||||
<div class="panel graph" style="display: block;"> \
|
<div class="recline-graph"> \
|
||||||
<div class="js-temp-notice alert alert-block"> \
|
<div class="panel graph" style="display: block;"> \
|
||||||
<h3 class="alert-heading">Hey there!</h3> \
|
<div class="js-temp-notice alert alert-block"> \
|
||||||
<p>There\'s no graph here yet because we don\'t know what fields you\'d like to see plotted.</p> \
|
<h3 class="alert-heading">Hey there!</h3> \
|
||||||
<p>Please tell us by <strong>using the menu on the right</strong> and a graph will automatically appear.</p> \
|
<p>There\'s no graph here yet because we don\'t know what fields you\'d like to see plotted.</p> \
|
||||||
|
<p>Please tell us by <strong>using the menu on the right</strong> and a graph will automatically appear.</p> \
|
||||||
|
</div> \
|
||||||
|
</div> \
|
||||||
</div> \
|
</div> \
|
||||||
</div> \
|
|
||||||
</div> \
|
|
||||||
',
|
',
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
@@ -65,7 +63,6 @@ my.Graph = Backbone.View.extend({
|
|||||||
self.redraw();
|
self.redraw();
|
||||||
});
|
});
|
||||||
this.elSidebar = this.editor.el;
|
this.elSidebar = this.editor.el;
|
||||||
this.render();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ this.recline.View = this.recline.View || {};
|
|||||||
//
|
//
|
||||||
// NB: you need an explicit height on the element for slickgrid to work
|
// NB: you need an explicit height on the element for slickgrid to work
|
||||||
my.SlickGrid = Backbone.View.extend({
|
my.SlickGrid = Backbone.View.extend({
|
||||||
tagName: "div",
|
|
||||||
className: "recline-slickgrid",
|
|
||||||
|
|
||||||
initialize: function(modelEtc) {
|
initialize: function(modelEtc) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.el = $(this.el);
|
this.el = $(this.el);
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ if (typeof VMM !== 'undefined') {
|
|||||||
//
|
//
|
||||||
// Timeline view using http://timeline.verite.co/
|
// Timeline view using http://timeline.verite.co/
|
||||||
my.Timeline = Backbone.View.extend({
|
my.Timeline = Backbone.View.extend({
|
||||||
tagName: 'div',
|
|
||||||
|
|
||||||
template: ' \
|
template: ' \
|
||||||
<div class="recline-timeline"> \
|
<div class="recline-timeline"> \
|
||||||
<div id="vmm-timeline-id"></div> \
|
<div id="vmm-timeline-id"></div> \
|
||||||
@@ -46,18 +44,17 @@ my.Timeline = Backbone.View.extend({
|
|||||||
);
|
);
|
||||||
this.state = new recline.Model.ObjectState(stateData);
|
this.state = new recline.Model.ObjectState(stateData);
|
||||||
this._setupTemporalField();
|
this._setupTemporalField();
|
||||||
this.render();
|
|
||||||
// can only call _initTimeline once view in DOM as Timeline uses $
|
|
||||||
// internally to look up element
|
|
||||||
if ($(this.elementId).length > 0) {
|
|
||||||
this._initTimeline();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var tmplData = {};
|
var tmplData = {};
|
||||||
var htmls = Mustache.render(this.template, tmplData);
|
var htmls = Mustache.render(this.template, tmplData);
|
||||||
this.el.html(htmls);
|
this.el.html(htmls);
|
||||||
|
// can only call _initTimeline once view in DOM as Timeline uses $
|
||||||
|
// internally to look up element
|
||||||
|
if ($(this.elementId).length > 0) {
|
||||||
|
this._initTimeline();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ my.Transform = Backbone.View.extend({
|
|||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.el = $(this.el);
|
this.el = $(this.el);
|
||||||
this.render();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user