Skip to content

Instantly share code, notes, and snippets.

@benediktarnold
Created April 26, 2012 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benediktarnold/2497756 to your computer and use it in GitHub Desktop.
Save benediktarnold/2497756 to your computer and use it in GitHub Desktop.
If you want a yui Panel act as a WidgetParent there is a problem rendering the child Widgets in the in the right parent node. The default location is the panel's contentBox, but in general you want it in the panel's body.
<!doctype html>
<html>
<head>
<title></title>
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">
<script type="text/javascript">
// Create a new YUI instance and populate it with the required modules.
YUI({filter:'RAW'}).use(['tabview','panel'], function (Y) {
var tabview = new Y.TabView({
children: [{
label: 'foo',
content: '<p>foo content</p>'
}, {
label: 'bar',
content: '<p>bar content</p>'
}, {
label: 'baz',
content: '<p>baz content</p>'
}]
});
var tabview2 = new Y.TabView({
children: [{
label: 'foo2',
content: '<p>foo content</p>'
}, {
label: 'bar2',
content: '<p>bar content</p>'
}, {
label: 'baz2',
content: '<p>baz content</p>'
}]
});
function WidgetStdModParent(config){
Y.after(this._changeChildrenContainer, this, "_renderBox");
}
WidgetStdModParent.prototype = {
_changeChildrenContainer: function(){
var body = Y.Node.create("<div></div>");
this._childrenContainer = body
this.setStdModContent(Y.WidgetStdMod.BODY,body);
}
}
var MyPanel = Y.Base.create("myWid", Y.Panel, [Y.WidgetParent,WidgetStdModParent]);
var panel = new MyPanel({
buttons: [
{
value : 'Close',
section: 'footer',
classNames: ['default close'],
action : function (e) {
e.preventDefault();
this.hide();
}
}
]
});
panel.add(tabview);
panel.add(tabview2);
panel.render('#target');
panel.show();
});
</script>
<div id="target"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment