My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 954: Don't modify passed-in eventSource items
1 person starred this issue and may be notified of changes. Back to list
Status:  Released
Owner:  ----
Closed:  Jun 2014


Sign in to add a comment
 
Reported by gsusmon...@gmail.com, May 16, 2011
Hello,

I am trying to re initialice the calendar several times (page is refreshed by AJAX).
The point is that my initialization options are:

var calendar_options = {
        header: {
            left:   null,
            center: 'prev title next',
            right:  'today'
        },
        loading: show_loading, 
        weekMode: 'fixed',
        events: get_events,
    },

Where 'get_events' is a function to get new events via AJAX. The initialization is done via:	
$('#calendar').fullCalendar(calendar_options);

The firts time it works. Next attempt didnt fire the AJAX get of the events.


Looking into the fullcalendar.js . I discovered these lines (lines arounf 144 in fullcalendar.js version 1.5.1)

	// would like to have this logic in EventManager, but needs to happen before options are recursively extended
	var eventSources = options.eventSources || [];
	delete options.eventSources;
	if (options.events) {
		eventSources.push(options.events);
		delete options.events;
	}
	

	options = $.extend(true, {},
		defaults,
		(options.isRTL || options.isRTL===undefined && defaults.isRTL) ? rtlDefaults : {},
		options
	);
	
Where it seems that options are deleted BEFORE being extended. It means that the original options, the ones supplied, are modified in the initialization.
So, reusing the object is not possible.

I avoid the problem by modifiying my call to 

$('#calendar').fullCalendar($.extend({},calendar_options,{events: get_events}));

However I wonder if the blocks on fullcalendar could be swapped (make extend before delete). This would avoid the side effect for another people's code.
			
In any case, Thanks for your awesome work!


-Jesus-
Aug 14, 2013
Project Member #4 adamrs...@gmail.com
(No comment was entered for this change.)
Labels: -Type-Bug Type-Behavior
Sep 22, 2013
Project Member #5 adamrs...@gmail.com
(No comment was entered for this change.)
Labels: milestone-date
Jan 25, 2014
Project Member #6 adamrs...@gmail.com
v2.0.0-beta no longer does this.
http://arshaw.com/fullcalendar/docs2/

please check it out. thanks.
May 25, 2014
Project Member #7 adamrs...@gmail.com
(No comment was entered for this change.)
Status: Implemented
May 27, 2014
Project Member #8 adamrs...@gmail.com
actually, the fixes i made did not account for not mutating the passed in "eventSources", so changing this back to accepted. will get this eventually. but v2 will have this issue fixed for most cases (if you are just using the `events` option for example)
Status: Accepted
Jun 2, 2014
Project Member #9 adamrs...@gmail.com
V2 was released but this fix was not in it. Will get to it in future versions.

As I mentioned, the `options` object will not be modified except for individual `eventSource` objects that have been passed in.
Summary: Don't modify passed-in eventSource items (was: Don't modify passed-in options object)
Labels: -Type-Behavior -milestone-date Type-Bug
Jun 15, 2014
Project Member #11 adamrs...@gmail.com
this issue has been addressed and version 2.0.1 has been released: http://arshaw.com/fullcalendar/download/
Status: Released
Sign in to add a comment

Powered by Google Project Hosting