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

Region show empties #3305

Closed
scott-w opened this issue Jan 29, 2017 · 7 comments
Closed

Region show empties #3305

scott-w opened this issue Jan 29, 2017 · 7 comments

Comments

@scott-w
Copy link
Member

scott-w commented Jan 29, 2017

Description

When we show a view with template: false in a Region, the result removes the template it's bound to.

Expected behavior

The view should bind to the existing template.

Actual behavior

The existing template code is deleted.

Environment

  1. Marionette version: latest
  2. Backbone version: any
  3. Additional build tools, etc: none

Also

I'm posting this from my phone for discussion. I'll fill it out a bit more when I'm at a computer. Whether it's a bug or whether we should ensure we've documented the current behaviour, I don't know yet. I'm open to suggestions.

@scott-w
Copy link
Member Author

scott-w commented Jan 29, 2017

Right, now I've had some time to think about it: I think Marionette is doing the right thing. If we have multiple subviews looking at, potentially, the exact same HTML, it's easy for the developer to create event handlers on the same HTML without realising.

I think we should check the documentation and ensure we're clear that region#show (and by extension view#showChildView) will always delete the HTML before it puts the new view on top.

A second point to consider: do we want to add an option to override this default behaviour? Perhaps a hook point of some sort?

@scott-w
Copy link
Member Author

scott-w commented Jan 30, 2017

On the second point, the following from @blikblum can be used http://codepen.io/blikblum/pen/oBpjrm?editors=1010#0

@paulfalgout
Copy link
Member

I think the usefulness of template: false is limited to code examples where you don't want to flush out the entirety of the of the view functionality.. like if you're making a fiddle.

Otherwise any rendered view should be attached to the el.

I'd also like to point out that initially everyone was putting the showChildViews in onRender which of course is a bad idea if the parent view is already rendered.. so it needs to be done in initialize which sucks if you intend to re-render that view later on the client-side.. thus #3243

The one possible issue this brought up is that replaceElement doesn't really work with pre-rendered DOM where the view's el and the region el begin as the same element.

@paulfalgout
Copy link
Member

Actually replaceElement does work with pre-rendered DOM on next. http://codepen.io/anon/pen/xgpLba?editors=1010#0

@paulfalgout
Copy link
Member

This whole thing did bring up: #3306

@paulfalgout
Copy link
Member

I also think this issue is all docs and is covered by: #3128

There is a problem in v3.1 related to this, but it was fixed #3260

@paulfalgout
Copy link
Member

I think this is ready to be closed and is handled in other open issues.. Feel free to reopen if there's something left to address.

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