PDA

View Full Version : [OPEN] LayoutRegion.hasPanel



jarrednicholls
12 Nov 2006, 12:24 AM
Bug when you pass a panel object in, it's passing in the panel object itself into the MixedCollection "get" function (i.e. this.panels.get(id)) instead of its id (i.e. this.panels.get(panel.getId()) )...yes the parameter name is "id" for hasPanel, but I thought it was unintuitive to have to use the panel ID rather than the panel itself...so this isn't really a bug I guess. Bah, whatever :-)

jack.slocum
12 Nov 2006, 4:59 AM
This is what I have:


hasPanel : function(panel){
return this.getPanel(panel) ? true : false;
}

And:


getPanel : function(id){
if(typeof id == 'object'){ // must be panel obj
return id;
}
return this.panels.get(id);
}

So if you pass in a panel object it should typeof to 'object' and return true. Is that the same code you have?

jarrednicholls
12 Nov 2006, 9:00 AM
it sure is....but the problem is if the panel is closed/removed from a region and you're testing that region to see if the panel is still showing by using hasPanel, you get a false-positive.

If there's another method I should use besides iterating through this.panels.items manually, let me know.

jack.slocum
12 Nov 2006, 6:59 PM
Good point. I will correct that.

jack.slocum
12 Nov 2006, 7:00 PM
hasPanel : function(panel){
if(typeof panel == 'object'){ // must be panel obj
panel = panel.getId();
}
return this.getPanel(panel) ? true : false;
}

jarrednicholls
13 Nov 2006, 5:40 AM
Cool.