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

Differentiate between pre-existing nodes, and not pre-existing nodes #2154

Closed
jamesplease opened this issue Dec 21, 2014 · 1 comment
Closed
Milestone

Comments

@jamesplease
Copy link
Member

There are two general categories of views in Backbone. One category are pre-existing nodes that are unlikely to be rendered ever. An example of this would be creating a rootView and passing the body as the element, in a situation where the body already has a handful of nodes. The other category are views which may or may not have templates and are rendered throughout the application's lifecycle. The latter of the two categories is by far the most common.

Marionette does not distinguish between these two types of views, which creates some bad side effects. For instance, both sorts of LayoutViews are treated identically, which leads to some nasty bugs.

One way to resolve situations like that are to differentiate between these two use-cases. We can infer that a view exists based on two criteria: it has no template, and it has children nodes.

In other words:

_preExistingNode: function() {
  return !this.template && this.$el.children().length;
}

During the instantiation phase of any view, this would be used to dictate the behavior of the view. Take a LayoutView, for instance. Pre-existing nodes would have their regions instantiated instantly, and their UI would also be bound instantly. LayoutViews that aren't pre-existing would wait until the first render before doing these actions.

@paulfalgout
Copy link
Member

Pretty sure this is resolved in v3.1

@paulfalgout paulfalgout modified the milestones: v3.1, v3.x Sep 16, 2016
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

4 participants