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

Scheduler watch update events

Asked by Anonymous
1 month 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]
1 month 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>
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.