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

Reload single event from database

Asked by Daniel
10 years ago.

Hi!

I am using the Scheduler with JS.

I want to reload a single event (or all events) from the database. CAlling "loadEvents();" adds the events, but do NOT reload them.

PLEASE HELP!

Thanks,
Daniel

Answer posted by Dan Letecky [DayPilot]
10 years ago.

If you want to refresh the events it is better to use .events.list array instead of .events.add() method. Adding events one by one using .events.add() works too but it is slower (it refreshes the scheduler every time).

An example using DayPilot.request():

function loadEvents() {
  DayPilot.request("backend_events.php", function(result) {
      var data = eval("(" + result.responseText + ")");
      dp.events.list = data;
      dp.update();
  });
}

An example using jQuery:

function loadEvents() {
  $.post("backend_events.php", 
  function(data) {
      dp.events.list = data;
      dp.update();
  });
}

If you want to clear the existing events use this:

dp.events.list = [];
// call update if you want to display the emtpy scheduler
dp.update();

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.