I’ve created a new event on the dhtmlx calendar. I want to be able to refresh the calendar without having to reload the whole page, so I’ve added the following code to “onAfterLightbox()”
scheduler.attachEvent("onAfterLightbox", function (){
scheduler.clearAll();
scheduler.load("events.php");
return true;
});
Problem is that on the clearAll() function I get the error, “Uncaught TypeError: Cannot read property ‘!nativeeditor_status’ of undefined”. Of course, the problem is in the response code from events.php where tid hasn’t been returned:
“<?xml version='1.0' ?>”
From my point of view, that is exactly the point of why I would want to clearAll(), to wipe the board clean, and refresh the data. I have tried commenting out scheduler.load(), to be sure the error is in fact in the clearAll() function, and indeed it is. Other than this, there doesn’t appear to be any other errors or problems with the event, or editing the event a second, or third time. Is there any way around this? Have I missed something?
Hello,
assuming that the error happens after you save the lightbox, your onAfterLightbox handler creates a race state between the update request and data loading request - some times you’ll be getting the updated data, and other times it will look like changes hasn’t been saved.
If you are using this handler in order to refresh calendar after some changes were submitted to the db, the safer approach would be to use onAfterUpdate event of the dataProcessor. It will trigger after server return data action response, so there won’t be concurrent ajax requests and also will probably fix the “Uncaught TypeError” you get.
This is not exactly the answer to your original questions, however the race state of ajax request seems to be a bigger issue that may cause several different problems and it kind of doesn’t make much sense investigating other issues while this is not corrected.
Btw, why do you need to reload the data after closing lightbox? If it’s because of invalid response from the connector, probably it is a good idea to investigate the connector issue instead
clearAll removes all data about events, but it doesn’t clear data saving requests in progress ( which is probably a bug in the component )
If you have a support subscription, please open a ticket at support.dhtmlx.com
Still, why do you return empty “tid” value from a server side? If you do not want to use the existing data-save-confirmation logic ( as you are reloading all data anyway ) you can change the response of a server-side code to the next
<?xml version='1.0' ?><data></data>
It will be correctly processed on a client side, without any error messages.
Thank you @Aliaksandr and Stanislav. I’m very new with the scheduler and not entirely sure I even knew the right question to ask, or the right answer to provide. Anyway, apparently I was missing something, getting the response back from the connector. I have implemented the onAfterUpdate() function and that is working quite perfectly now. I knew as I had more time exploring and working with the scheduler I would gain more traction with it, and you opened the door to me of the dataProcessor API, which I had missed.
The objective from the outset was to deal with another issue. Without refreshing the data, after creating a new event if the user attempted to edit the event without a refresh this error was thrown:
“Uncaught TypeError: Cannot read property ‘end_date’ of undefined”.
It was the same root problem, a temporary sid, and an empty tid in the response from the connector. But either problem is solved now. Thanks again.
Get a guaranteed answer from DHTMLX technical support team
under the most suitable support plan