My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 940: events in fullcalendar from two different sources with the same id
1 person starred this issue and may be notified of changes. Back to list
Status:  WontFix
Owner:  ----
Closed:  Aug 2013


Sign in to add a comment
 
Reported by st4...@gmail.com, May 3, 2011
Hi, I load in my fullcalendar two different sources from db with json, some events have the same id and if i try to click on one of these I'm selecting the two events and if I try to move same behavior. Why not only for that who i clicked?

idem for the RemoveEvents method, that remove all events with the same ID.

how can I differentiate an event to another with the same id?
May 4, 2011
Project Member #1 althaus.it
This is working as intended. As stated in the doc [1]:

id: "Uniquely identifies the given event. Different instances of repeating events should all have the same id."

[1] http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
Status: Done
May 4, 2011
#2 st4...@gmail.com
Yes, I know that working as intended.
But if I load the events from two different sources, in this way:
$('#calendar').fullCalendar({
eventSources: [{"url":"myfeed.php"},{"url":"myfeed2.php"}]
});		
is possible that there are events with the same id, because the events are of two different calendars.

There is no way to differentiate the source?

for example to remove an event.. fullCalendar('removeEvents','1', myfeed.php) or fullCalendar('removeEvents','1', myfeed2.php)

or something that works in this way?

thanks.
May 6, 2011
Project Member #3 althaus.it
The ID a core handler, so you won't get around that easily. Depending on your app you could try to append an additional feed based ID to the event IDs. This way they would be unique again.

Dunno what Adam's point of view on this is, but as seems to be a more general problem, I'm removing the "Done" status.
Status: Discussing
May 6, 2011
#4 st4...@gmail.com
I think that fullcalendar may issue a "super ID / unique ID" to each event, distinct from the id that reading from the feed, or should adapt the management functions to the different sources.
May 15, 2011
#5 st4...@gmail.com
I have solved my problems loading the two different calendars with the parameters did and eid instead of id. infact so fullcalendar assigns a unique id = _id * fc .. and I fixed the update functions of the events with "if" for different sources.

for the function removeEvents I have rewrite in this way:

	function removeEventsNew(filter,source) {
		if (!filter) { // remove all
			cache = [];
			// clear all array sources
			
			for (var i=0; i<sources.length; i++) {
				if ($.isArray(sources[i].events)) {
					sources[i].events = [];
				}
			}
		}
		else{
			if (!$.isFunction(filter)) { // an event ID
				var id = filter + '';
				if(!source) { //classic behavior
				filter = function(e) {
					return e._id == id;
				};
				} else { // with source set
				filter = function(e) {
					if(e.source.url==source){
					//added by me
						if(e.did){ // my id -> did
							return e.did == id;
						}
						if(e.eid){ // my id -> eid
						return e.eid == id;
						}
					}
				};
				}
			}
			cache = $.grep(cache, filter, true);

			// remove events from array sources
			for (var i=0; i<sources.length; i++) {
				if ($.isArray(sources[i].events)) {
					sources[i].events = $.grep(sources[i].events, filter, true);
				}
			}
		}
		reportEvents(cache);
	}
Aug 13, 2013
Project Member #6 adamrs...@gmail.com
st4nny, using the filter is a good idea and is a good workaround for this.

at some point i will make event sources less unwieldy
Status: WontFix
Sign in to add a comment

Powered by Google Project Hosting