Просмотр исходного кода

setElement now part of renderqueue

Adam Shaw 8 лет назад
Родитель
Сommit
27f6e705d0
2 измененных файлов с 12 добавлено и 10 удалено
  1. 8 8
      src/Calendar.render.js
  2. 4 2
      tests/legacy/background-events.js

+ 8 - 8
src/Calendar.render.js

@@ -94,15 +94,13 @@ Calendar.mixin({
 
 
 	destroy: function() {
-		this.renderQueue.kill();
-
 		if (this.view) {
-			this.view.removeElement();
-
-			// NOTE: don't null-out this.view in case API methods are called after destroy.
-			// It is still the "current" view, just not rendered.
+			this.clearView();
 		}
 
+		this.renderQueue.kill();
+		// ^ TODO: should we let all rendering play out?
+
 		this.toolbarsManager.proxyCall('removeElement');
 		this.contentEl.remove();
 		this.el.removeClass('fc fc-ltr fc-rtl');
@@ -220,9 +218,10 @@ Calendar.mixin({
 
 			this.initBatchRenderingForView(newView);
 
-			newView.setElement($("<div class='fc-view fc-" + viewType + "-view' />"));
 			this.renderQueue.queue('_calendar', 'el', 'init', function() {
-				newView.el.appendTo(_this.contentEl);
+				newView.setElement(
+					$("<div class='fc-view fc-" + viewType + "-view' />").appendTo(_this.contentEl)
+				);
 			});
 
 			this.toolbarsManager.proxyCall('activateButton', viewType);
@@ -358,6 +357,7 @@ Calendar.mixin({
 	windowResize: function(ev) {
 		if (
 			ev.target === window && // so we don't process jqui "resize" events that have bubbled up
+			this.view &&
 			this.view.isDatesRendered
 		) {
 			if (this.updateViewSize(true)) { // isResize=true, returns true on success

+ 4 - 2
tests/legacy/background-events.js

@@ -98,8 +98,10 @@ describe('background events', function() {
 			it('renders "business hours" on whole days', function(done) {
 				options.businessHours = true;
 				options.eventAfterAllRender = function() {
-					expect($('.fc-nonbusiness').length).toBe(12); // there are 6 weeks. 2 weekend days each
-					done();
+					setTimeout(function() { // no trigger when business hours renders. this will have to do.
+						expect($('.fc-nonbusiness').length).toBe(12); // there are 6 weeks. 2 weekend days each
+						done();
+					}, 0)
 				};
 				$('#cal').fullCalendar(options);
 			});