[#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:
Rufus Pollock
2012-08-15 12:33:59 +01:00
parent c75e31a856
commit bc414e9f8c
5 changed files with 16 additions and 24 deletions

View File

@@ -13,8 +13,6 @@ if (typeof VMM !== 'undefined') {
//
// Timeline view using http://timeline.verite.co/
my.Timeline = Backbone.View.extend({
tagName: 'div',
template: ' \
<div class="recline-timeline"> \
<div id="vmm-timeline-id"></div> \
@@ -46,18 +44,17 @@ my.Timeline = Backbone.View.extend({
);
this.state = new recline.Model.ObjectState(stateData);
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() {
var tmplData = {};
var htmls = Mustache.render(this.template, tmplData);
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() {