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

Infinitely recursive view rerender, crash #3519

Closed
Prabhakar-Poudel opened this issue Feb 10, 2017 · 2 comments
Closed

Infinitely recursive view rerender, crash #3519

Prabhakar-Poudel opened this issue Feb 10, 2017 · 2 comments
Milestone

Comments

@Prabhakar-Poudel
Copy link

I was trying to prevent editing in month view and allow it only in agendaDay view.

I tried this:

viewRender(view) {
      if (view.type === 'month') {
        $('.full-calendar').fullCalendar('option', 'editable', false);
      }
}

I thought we could do that, but that definitely caused crash. Unfortunately I don't have time to reproduce to show an example. Just wanted to report it.

A hacky solution that I had to do to get desired behaviour was to:

viewRender(view) {
      if (view.type === 'month') {
          view.options.editable = false;
      }
}

just in case someone needs

@arshaw
Copy link
Member

arshaw commented Feb 10, 2017

thanks. there have been other reports that are somewhat related. the crux of the problem is that a view rerender is being called from within a viewRender callback, causing infinite recursion. there should be a safeguard against this.

@arshaw
Copy link
Member

arshaw commented Feb 12, 2017

Here's the root of the problem: a dynamic options change almost always results in a full view rerender, which calls the viewRender callback, which results in infinite recursion.

One potential solution: if the option being changed is already set to the given value, do nothing. This approach would prevent infinite rerenders. It would only result in 2 renders.

I've made a ticket for that here:
Optimization: dynamic option change, when no change, should not rerender

Another solution is to ignore rerenders that are initiated in the viewRender callback. Though I fear some people would want the ability to initiate a rerender, and this would constrain them.

FYI, the rerender does queue up until after the viewRender is executed, but still a type of recursion nonetheless.

Another solution: introduce a new callback that only gets called when the date range changes:
Callback when a view's type or dates change (viewChange?)

That would result in only 2 renders in your situation.

best solution for your case @Prabhakar-Poudel

Simply use view-specific options to specify editable:false for month view:

$('#cal').fullCalendar({
    editable: true,
    views: {
        month: {
            editable: false
        }
    }
});

Closing. Wontfix

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

No branches or pull requests

2 participants