Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ajax cache #70

Closed
augustocb23 opened this issue Jun 1, 2018 · 1 comment
Closed

Disable ajax cache #70

augustocb23 opened this issue Jun 1, 2018 · 1 comment

Comments

@augustocb23
Copy link

When the user creates a event and save it to database, just refreshing the page isn't enough to update the calendar, because the browser keeps the cache after loading a month.

JQuery has a option to disable the cache - cache : false - and will be great if it's available through the ajax option on calendar initialization.

And taking the opportunity... is there a way to do a "refresh" in the calendar, i.e., do a new ajax call to reload the events from the current month with the updated ones from the database?

@zabuto
Copy link
Owner

zabuto commented Jan 7, 2019

I'm currently working on v2 of the calendar and have incorporated your comments in this version. Thank you for your feedback!

The new v2 ajax setting can be string containing the URL to which the request is sent. In this case the cache is disabled: cache: false. Alternatively you can use a jQuery ajax settings object for more flexibility.

var ajaxSettings = this.settings.ajax;
if (null !== ajaxSettings) {
    if (typeof ajaxSettings === 'string') {
        ajaxSettings = {
            type: 'GET',
            url: ajaxSettings,
            cache: false
        };
    }
}

The v2 calendar emits custom events and has an extended api for more flexibility. You can refresh the data with zabuto_calendar('data') and listen to events calendar:data and calendar:data-fail.

var $el = $('#calendar');
$el.zabuto_calendar();
$el.zabuto_calendar('data');
$el.on('calendar:data', function (event) {
    /* do stuff */
});

@zabuto zabuto closed this as completed Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants