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

beforeViewDisplay trigger #111

Closed
wants to merge 1 commit into from

Conversation

dr-impossible
Copy link

This pull request adds a viewBeforeDisplay callback, which gets called before the current view is removed and replaced with another view.

Use Case: I've been using the popover plugin from Twitter Bootstrap to add popovers to events. The popovers are attached to the event element like below:

$('#calendar').fullCalendar({
  eventAfterRender: function(event, element, view) {
    element.popover({
      title: event.title
      content: event.description
    });
  }
});

But, I was having an issue where the popovers would get stuck whenever the user paged over to another view. The event elements that the popovers were attached to disappear by the time viewDisplay gets called, so there doesn't seem to be a way to hide them after the view changed. Adding the viewBeforeDisplay callback makes it easy to clean up anything added to the current view before it changes.

$('#calendar').fullCalendar({
  viewBeforeDisplay: function(view) {
    $('.fc-event').popover('hide');
  }
});

useful for cleaning up anything added to the view (e.g. popovers) before those elements are destroyed
@arshaw
Copy link
Member

arshaw commented Jul 27, 2013

let's rename to beforeViewDisplay to be consistent with other naming options.

To prevent confusion, there is PR #15 , which is slightly different:

  • beforeViewRender / viewRender gets called when the DOM structure of the view has to be re-built
  • beforeViewDisplay / viewDisplay gets called when the current view is changed, but doesn't necessarily have to be rendered, as it might have been previously rendered but just hidden/shown.

@dr-impossible
Copy link
Author

I agree, the beforeViewDisplay is more natural, I just thought that viewBeforeDisplay would be consistent with the convention used to name eventAfterRender.

Should I create a new pull request with the updated name? I've never done this on a public project before.

@arshaw
Copy link
Member

arshaw commented Jul 29, 2013

no thanks, i got it

@arshaw
Copy link
Member

arshaw commented Aug 7, 2013

came up with something better, a eventDestroy callback, in fb1dbd6, in the upcoming release branch.

in your scenario, you would end up doing something like this:

...
    eventDestroy: function(event, element) {
        element.popover('hide');
    }
...

full docs to come

@arshaw arshaw closed this Aug 7, 2013
@dr-impossible
Copy link
Author

Nice, looking forward to seeing this in the next release 👍

@arshaw
Copy link
Member

arshaw commented Aug 11, 2013

just released in v1.6.3

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

Successfully merging this pull request may close these issues.

2 participants