2

I am working with the jQuery weekcalendar to show a web based calendar with appointments. Some build-in functions like setEventUserId store some variables in the calEvent.

What do I have to do to store custom variables in this calEvent object?

Something like:

setEventCategoryId: function(calendarId, calEvent, calendar) {
  calEvent.calendarId = calendarId;
  return calEvent;
},
getEventCategoryId: function(calEvent, calendar) {
  return calEvent.calendarId;
}

But when do I call this method? And is it enough to only have this piece of code to store the variable?

Any input is much appreciated.

Nope
  • 22,147
  • 7
  • 47
  • 72
nimrod
  • 5,595
  • 29
  • 85
  • 149

1 Answers1

0

The variables stored internally by the plugin are used internally by the plugin. Your custom variables are not used internally by the plugin so it makes no sense to store them using the plugin.

You can store arbitrary data against elements using jQuery's .data() function.

http://api.jquery.com/data/

For example to set:

$(calEvent).data('calendarId', calendarId);

To retrieve:

var calendarId = $(calEvent).data('calenderId');
leftclickben
  • 4,564
  • 23
  • 24