Search
Calendar.itemCreated Event
See Also
 






Raised when an item is created.

Namespace: MindFusion.Scheduling
File: Calendar.js

 Syntax

JavaScript  Copy Code

EventDispatcher itemCreated

 Event Data

The event handler method receives the following arguments:
sender
A Calendar instance, which is the source of the event. This object will be passed to the handler function as the first argument.
args
An ItemModifiedEventArgs instance, which contains event data. This object will be passed to the handler function as the second argument.

 Example

The following example attaches a handler to the itemCreated event of a calendar. In the handler method we check if the action was in-place editing and the start day of the item is Thursday. If yes, we do not allow the subject to be modified - we discard the change by copying the subject from the item before the modification.

JavaScript  Copy Code

var p = MindFusion.Scheduling;

// attach a handler - when a calendar item is created
calendar.itemCreated.addEventListener(handleItemCreated);

function handleItemCreated(sender, args) {
    //the args.item argument gives information about the item that was created
    if(args.action == p.ItemModifyAction.InplaceEdit && args.startTime.dayOfWeek == 3)
      {
        //copy the subject
        args.item.subject = args.oldItem.subject;
           
      }
}

 See Also