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

Add a render method to view that only renders if the view is active and attached to the dom #346

Open
mandragorn opened this issue Sep 14, 2017 · 4 comments

Comments

@mandragorn
Copy link
Contributor

No description provided.

@mandragorn
Copy link
Contributor Author

something like this:

  /**
   * Renders the view only if it is active and part of the DOM.
   * @method _renderIfDisplayed
   * @private
   */
  _renderIfDisplayed: function() {
    if (this.isActive() && this.isAttached()) {
      this.render();
    }
  }

@mandragorn
Copy link
Contributor Author

but not private and probably named something different.

@kentmw
Copy link
Contributor

kentmw commented Sep 26, 2017

Why does the caller have to care about if it's attached? I'd rather just add this attached and active logic to the prerender method.

prerender: function() {
  return this.isAttached() && this.isActive();
}

The outward API shouldn't have to know or care if it's attached when calling render.

@kentmw
Copy link
Contributor

kentmw commented Sep 26, 2017

Specifically, the view rendering should know if the content inside it will be affected if rendered detatched or deactivated. The view rendering should add it's own prerender logic to block a render command. I don't want to have to think about whether to use myChildView.render() or myChildView.renderIfAttached()

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