search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Scheduler watch update events

Asked by Anonymous
7 days ago.

Hello.

How to watch changes in events list?

I'm using DayPilot version for vue3.

This example doesn't work.

<DayPilotScheduler :config="config" ref="schedulerRef" id="schedulerRef" />


watch( () => schedulerRef.value?.control.events.list, (newValue) => { console.log('changed') }, { deep: true }, );

Answer posted by Dan Letecky [DayPilot]
5 days ago.

In order to detect changes performed by the Scheduler UI in Vue, you need to watch the source object. Like this:

<template>
  <DayPilotScheduler
    :events="events"
    :resources="resources"
  />
</template>

<script setup>
import { DayPilotScheduler } from '@daypilot/daypilot-lite-vue';
import { ref, onMounted, watch } from 'vue';

const events = ref([]);
const resources = ref([]);

const loadEvents = () => {
  events.value = [
    { id: 1, start: "2025-01-10T00:00:00", end: "2025-01-15T00:00:00", text: "Event 1", resource: "A" },
  ];
};

const loadResources = () => {
  resources.value = [
    { id: "A", name: "Resource A" },
    { id: "B", name: "Resource B" },
    // Add more resources as needed
  ];
};

watch(
  events,
  () => {
    console.log("events.value", events.value);
  },
  { deep: true }
);

onMounted(() => {
  loadResources();
  loadEvents();
});
</script>
New Reply
This reply is
Attachments:
or drop files here
Your name (optional):