scheduler.load() fail at the second call

I’ve a page with a scheduler loaded one time, and I need to load another URL if I click a button. But when I click the button the scheduler load the same URL of the first time, although I called aonther URL. Example:

[code]var url = “http://server/app/method1”;
console.log(url);
scheduler.load(url);

scheduler.clearAll();

var url = “http://server/app/method2”;
console.log(url);
scheduler.load(url);[/code]

The second time scheduler loads the server/app/method1 !! (I’ve seen it at Firefox console, the GET URL is the same the two times).

Is it a bug? Is there a way to prevent that?

Hi,
it does not seems to happen in our samples. E.g. open this sample docs.dhtmlx.com/scheduler/sample … abase.html
and execute following code in browser console:

[code]scheduler.clearAll()

var url = “http://docs.dhtmlx.com/scheduler/samples/01_initialization_loading/data/events.php”;
scheduler.load(url );

scheduler.clearAll();

var url = “http://docs.dhtmlx.com/scheduler/samples/01_initialization_loading/data/events.xml”;
scheduler.load(url);[/code]There will be two different urls in console, as expected

Check this example: dimas.cat/demo/demo_load.htm

At the first page load the url loaded is events.xml:

10:18:29.582 GET http://dimas.cat/demo/events.xml [HTTP/1.1 304 Not Modified 131ms] 10:18:29.486 "http://dimas.cat/demo/events.xml"
When I click the button “Test second load”, althought I’ve changed the URL to load events2.xml, events.xml is loaded instead:

10:18:33.784 GET http://dimas.cat/demo/events.xml [HTTP/1.1 304 Not Modified 260ms] 10:18:33.732 "http://dimas.cat/demo/events2.xml"

:cry:

Change code like next

function loadnew(param) { if (param == 1) var url = "http://dimas.cat/demo/events2.xml"; else var url = "http://dimas.cat/demo/events.xml"; console.log(url); scheduler.load(url); scheduler.clearAll(); }

In dyn loading mode, call to clearAll triggers immediate data loading, so if you want to change the active url, clearAll need to be placed after scheduler.load. ( due to async. nature of load command, clearAll will be executed before real data loading )

Thx Stanislav, this is the way! Now it loads the correct URL, but when I load the page for the first time it call the URL two times.

09:30:07.618 GET http://dimas.cat/demo/events.xml [HTTP/1.1 304 Not Modified 130ms] 09:30:07.765 GET http://dimas.cat/demo/events.xml [HTTP/1.1 304 Not Modified 133ms]
I updated the demo: dimas.cat/demo/demo_load.htm

I solved this with this line of code, but I don’t know if it’s the better/optimum way to avoid this double call:

if (scheduler.getEvents().length > 0) scheduler.clearAll();

Thx

Returning to the topic, I need to scheduler.clearAll() don’t reload the events, only clear it. That is scheduler.clearAll() don’t have to load any events, only remove all the events from the scheduler.

How can I do it?

That is caused by combination of setLoadMode and clearAll.
When you are using setLoadMode clearAll will cause data reloading ( without setLoadMode clearAll will remove data and will not trigger the code )

Is it a bug? I can’t understand the reason that setting the setLoadMode cause data reloading.

Not setting setLoadMode can cause lag to the client side (DHTMLX Scheduler) or it only affects the SQL event loading time?

There is a technical reason for such behavior, but from your perspective it definitely looks as a bug.

We will fix it in the next update. clearAll call will clear all data, reset cache and will not trigger automatic data loading

Do you know a planned version for that? Will we have some new version soon? Thx

ping?

In the recent 4.4 version the “What’s New” doc says:

Is it related to this forum post? What effect have this change to our scheduler implementations?

Thx

Hello,
from I can see, this is not related. This fix targeted an error which happened when you have dataprocessor request for some item in progress (ajax sent but not completed yet) and clear scheduler using scheduler.clearAll before the request is completed - dataProcessor did not register that scheduler has been emptied and tried to update non-existing event after receiving server response. Now it should work correctly.

Although, the issue with setLoadMode/clearAll seems to be fixed as well. It doesn’t trigger data loading if i call scheduler.clearAll() in this demo
docs.dhtmlx.com/scheduler/sample … abase.html

And since scheduler.update_view(which triggers dyn loading) is not called from clearAll anymore, it shouldn’t do anything except for clearing scheduler data and removing displayed events from DOM
github.com/DHTMLX/scheduler/blo … r.js#L4412
github.com/DHTMLX/scheduler/blo … r.js#L5104

I am still experimenting the same behavior. My code:

scheduler.setCurrentView(data_inici); scheduler.load("<?php echo base_url(); ?>get_events/"+id, function(){ (...) }); if ({first_load} === false) scheduler.clearAll();
If I remove the if ({first_load} === false) the scheduler calls get_events 2 times at the first load.
If I put the clearAll() method before scheduler.load() the url isn’t updated and get_events calls the last id loaded
If I remove clearAll() the get_events url is not loaded

Same here:

scheduler.clearAll();
scheduler.parse(new_events,‘json’);
scheduler.updateCollection(“timelineList”, new_list);
scheduler.updateCollection(“units”, new_list);

…code code code…

scheduler.init(‘scheduler_here’, new Date(), “{{ calendarView() }}”);
scheduler.setLoadMode(“month”);
scheduler.load(“calendar/data”,“json”);

Just updated to 4.4.0
The events are filtered server-side and than i feed them to scheduler.parse(new_events,‘json’). the scheduler looks great…for a split second, than " /calendar/data?timeshift=-120&uid=1488895193918&from=2017-02-28&to=2017-03-31" gets called and all hope is lost!
If i remove “clearAll” OR “setLoadMode” everything is ok.
I saw the post with $$(“scheduler”).data.silent(function(){this.clearAll()} or something like that. But that seems like a workaround and even so, I can’t get that to work.

Thanks