# Event Overlaps (JavaScript Event Calendar) | DayPilot Pro for JavaScript Demo

> Read more about [calendar event overlaps](https://doc.daypilot.org/calendar/event-overlaps/).

## Links

- Canonical HTML: /demo/calendar/eventoverlaps.html
- Source HTML folder: /demo/calendar/
- Catalog root: /demo/
- Catalog: /demo/llms.txt

## Source

### Inline demo script 1

```javascript
const dp = new DayPilot.Calendar("dp", {
            viewType: "Week",
            eventDeleteHandling: "Update",
            onTimeRangeSelected: async args => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                if (modal.canceled) {
                    return;
                }
                dp.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result
                });
                dp.clearSelection();
                dp.message("Created");
            },
            allowEventOverlap: false
        });
        dp.init();

        const app = {
            init() {
                this.loadEventData();
            },
            loadEventData() {
                const events = [
                    {
                        start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(11),
                        end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(14),
                        id: DayPilot.guid(),
                        text: "Event 1"
                    },
                    {
                        start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(15),
                        end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(17),
                        id: DayPilot.guid(),
                        text: "Event 2"
                    },
                ];
                dp.update({events});
            }
        };
        app.init();
```

