[#211,view][s]: switch show/hide from events to explicit methods - fixes #211.

This commit is contained in:
Rufus Pollock
2012-08-15 10:17:36 +01:00
parent d43b9633ec
commit 6f78b7b1be
5 changed files with 55 additions and 48 deletions

View File

@@ -32,12 +32,6 @@ my.Timeline = Backbone.View.extend({
this.el = $(this.el);
this.timeline = new VMM.Timeline();
this._timelineIsInitialized = false;
this.bind('view:show', function() {
// only call _initTimeline once view in DOM as Timeline uses $ internally to look up element
if (self._timelineIsInitialized === false) {
self._initTimeline();
}
});
this.model.fields.bind('reset', function() {
self._setupTemporalField();
});
@@ -66,6 +60,13 @@ my.Timeline = Backbone.View.extend({
this.el.html(htmls);
},
show: function() {
// only call _initTimeline once view in DOM as Timeline uses $ internally to look up element
if (this._timelineIsInitialized === false) {
this._initTimeline();
}
},
_initTimeline: function() {
var $timeline = this.el.find(this.elementId);
// set width explicitly o/w timeline goes wider that screen for some reason