JavaScript API Reference/Ab.timeline.TimelineController object

addOnCreateEvent(eventHandler)

Set the JavaScript event handler that will be called by the timeline control when the user creates a new event using drag-and-drop. Use it to implement custom event validation (i.e. if you want to check whether the event is valid according to additional rules or parameters).

Parameters:

  • eventHandler (function reference): the function should be defined in your code, and should accept one parameter:
    • event (object): Ab.timeline.Event object that is about to be created.


Returns:
true if the event can be created and displayed; false if the event is not allowed and should not be created.

Example:

timeline.addOnCreateEvent(onCreateEvent);
...
function onCreateEvent(event) {
// events cannot be created in the first timeline row
return (event.getRow() > 0);
}