cmv-app
cmv-app copied to clipboard
_LayoutMixin mutates the prototype object panes
How often can you reproduce it?
- [ ] Always
- [x] Sometimes
- [ ] Rarely
- [ ] Unable
- [ ] I didn’t try
Description:
The initPanes
function is adding properties to the this.panes
object. This results in a object that is quite different from the default if more than one instance of cmv is created.
For instance:
this.panes.outer = new BorderContainer({
id: 'borderContainerOuter',
design: 'sidebar',
gutters: false
}).placeAt(container);
This should be avoided because when cmv initializes subsequent times after this object is modified, it fails because lang.clone
is unable to handle complex objects like BorderContainer
.
Steps to reproduce:
- Startup cmv, then try to create a new instance of an app.
Expected results:
CMV should be able to initialize more than once. Why? I am working on an interface that uses cmv in a single page app, and there are situations where cmv is added and removed from the page. This shouldn't be a problem.
Actual results:
CMV fails to initialize a second time.
Environment:
Software | Version |
---|---|
CMV Version | 2.0.0beta |
Browser | Chrome |
Operating system | Windows 7 x64 |
The original panes are preserved in this.defaultPanes
so they can be restored before initPanes
method is called a second time. Clearly, you'll want to iterate through this.panes
to destroy all the existing panes before initializing them again.
Have you messed with destroyRecursive
or destroy
at all? Should one of those perhaps be implemented?
In theory, if I use dijit/registry
and do something like:
registry.toArray().forEach(function(item){
item.destroyRecursive();
});
It should resolve the issues.
But as you might expect each widget may utilize this at different levels and I can tell already, it is going to be a big problem I think throughout cmv. I think a lot of widgets don't clean up after themselves properly when destroy
is called on them, so when they are reinitialized they have issues.
The original panes are preserved in this.defaultPanes so they can be restored before initPanes method is called a second time
Why would initPanes
be called a second time unless the app.startup
method is called again?
Hard to know your intent when you say CMV should be able to initialize more than once
. I interpret this to mean starting an app from startup
method.
Oh, I misunderstood. So basically what I'm suggesting is this. We have a single page application where cmv is initialized based on the current state of the page. But CMV is not always loaded on the page.
For example:
- CMV is started on a dom node with a particular config.
- Some other part of the app changes, and cmv is removed (destroyed) from the dom
- A new dom node is created and CMV is initialized again, on that new dom node
Basically, on that new dom node, cmv needs to be able to re-initialize itself from scratch, but if there are panes left over from the previous startup these issues will arise.