Explorar o código

protection against event segments not having been immediately rendered

Adam Shaw %!s(int64=11) %!d(string=hai) anos
pai
achega
9774b6db3a
Modificáronse 1 ficheiros con 9 adicións e 7 borrados
  1. 9 7
      src/common/View.js

+ 9 - 7
src/common/View.js

@@ -529,7 +529,7 @@ var View = fc.View = Class.extend({
 
 
 	// Signals that all events have been rendered
 	// Signals that all events have been rendered
 	triggerEventRender: function() {
 	triggerEventRender: function() {
-		this.eventSegEach(function(seg) {
+		this.renderedEventSegEach(function(seg) {
 			this.trigger('eventAfterRender', seg.event, seg.event, seg.el);
 			this.trigger('eventAfterRender', seg.event, seg.event, seg.el);
 		});
 		});
 		this.trigger('eventAfterAllRender');
 		this.trigger('eventAfterAllRender');
@@ -538,7 +538,7 @@ var View = fc.View = Class.extend({
 
 
 	// Signals that all event elements are about to be removed
 	// Signals that all event elements are about to be removed
 	triggerEventDestroy: function() {
 	triggerEventDestroy: function() {
-		this.eventSegEach(function(seg) {
+		this.renderedEventSegEach(function(seg) {
 			this.trigger('eventDestroy', seg.event, seg.event, seg.el);
 			this.trigger('eventDestroy', seg.event, seg.event, seg.el);
 		});
 		});
 	},
 	},
@@ -562,7 +562,7 @@ var View = fc.View = Class.extend({
 
 
 	// Hides all rendered event segments linked to the given event
 	// Hides all rendered event segments linked to the given event
 	showEvent: function(event) {
 	showEvent: function(event) {
-		this.eventSegEach(function(seg) {
+		this.renderedEventSegEach(function(seg) {
 			seg.el.css('visibility', '');
 			seg.el.css('visibility', '');
 		}, event);
 		}, event);
 	},
 	},
@@ -570,22 +570,24 @@ var View = fc.View = Class.extend({
 
 
 	// Shows all rendered event segments linked to the given event
 	// Shows all rendered event segments linked to the given event
 	hideEvent: function(event) {
 	hideEvent: function(event) {
-		this.eventSegEach(function(seg) {
+		this.renderedEventSegEach(function(seg) {
 			seg.el.css('visibility', 'hidden');
 			seg.el.css('visibility', 'hidden');
 		}, event);
 		}, event);
 	},
 	},
 
 
 
 
-	// Iterates through event segments. Goes through all by default.
+	// Iterates through event segments that have been rendered (have an el). Goes through all by default.
 	// If the optional `event` argument is specified, only iterates through segments linked to that event.
 	// If the optional `event` argument is specified, only iterates through segments linked to that event.
 	// The `this` value of the callback function will be the view.
 	// The `this` value of the callback function will be the view.
-	eventSegEach: function(func, event) {
+	renderedEventSegEach: function(func, event) {
 		var segs = this.getEventSegs();
 		var segs = this.getEventSegs();
 		var i;
 		var i;
 
 
 		for (i = 0; i < segs.length; i++) {
 		for (i = 0; i < segs.length; i++) {
 			if (!event || segs[i].event._id === event._id) {
 			if (!event || segs[i].event._id === event._id) {
-				func.call(this, segs[i]);
+				if (segs[i].el) {
+					func.call(this, segs[i]);
+				}
 			}
 			}
 		}
 		}
 	},
 	},