Skip to content

Commit

Permalink
adds null check before adding event source
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdixon committed Oct 15, 2017
1 parent d3b7649 commit 9d4446b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions addon/components/full-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,13 @@ export default Ember.Component.extend(InvokeActionMixin, {
* re-render if changes are detected
*/
observeEvents: observer('events.[]', function () {
const fc = this.$();
fc.fullCalendar('removeEvents');
fc.fullCalendar('addEventSource', this.get('events'));
const fc = this.$();
const events = this.get('events');

if (events) {
fc.fullCalendar('removeEvents');
fc.fullCalendar('addEventSource', this.get('events'));
}
}),

/**
Expand All @@ -230,9 +234,13 @@ export default Ember.Component.extend(InvokeActionMixin, {
*/
observeEventSources: observer('eventSources.[]', function () {
const fc = this.$();

fc.fullCalendar('removeEventSources');

this.get('eventSources').forEach(function(source){
fc.fullCalendar('addEventSource', source);
if (source) {
fc.fullCalendar('addEventSource', source);
}
});
}),

Expand All @@ -253,6 +261,7 @@ export default Ember.Component.extend(InvokeActionMixin, {
viewNameDidChange: Ember.observer('viewName', function() {
const viewName = this.get('viewName');
const viewRange = this.get('viewRange');

this.$().fullCalendar('changeView', viewName, viewRange);

// Call action if it exists
Expand Down

0 comments on commit 9d4446b

Please sign in to comment.