Skip to content

Instantly share code, notes, and snippets.

@mattparker
Created March 29, 2010 13:12
Show Gist options
  • Save mattparker/347817 to your computer and use it in GitHub Desktop.
Save mattparker/347817 to your computer and use it in GitHub Desktop.
<div>
<button id="show1">Show panel1</button>
<button id="hide1">Hide panel1</button>
</div>
<div id="container"></div>
<div id="panel1">
<div class="hd">Panel #1 from Markup</div>
<div class="bd">This is a Panel that was marked up in the document.</div>
<div class="ft">End of Panel #1</div>
</div>
<div>
<button id="show2">Show panel2</button>
<button id="hide2">Hide panel2</button>
</div>
<script type="text/javascript">
// Instantiate a Panel from markup
YAHOO.namespace("example.container");
YAHOO.example.container.panel1 = new YAHOO.widget.Panel("panel1", { width:"200px", visible:false, constraintoviewport:true } );
YAHOO.example.container.panel1.render();
// Instantiate a Panel from script
YAHOO.example.container.panel2 = new YAHOO.widget.Panel("panel2", { width:"200px", visible:false, draggable:false, close:false } );
YAHOO.example.container.panel2.setHeader("Panel #2 from Script");
YAHOO.example.container.panel2.setBody("This is a dynamically generated Panel.");
YAHOO.example.container.panel2.setFooter("End of Panel #2");
YAHOO.example.container.panel2.render("container");
</script>
<script type="text/javascript">
YAHOO.util.Event.addListener("show1", "click", YAHOO.example.container.panel1.show, YAHOO.example.container.panel1, true);
YAHOO.util.Event.addListener("hide1", "click", YAHOO.example.container.panel1.hide, YAHOO.example.container.panel1, true);
YAHOO.util.Event.addListener("show2", "click", YAHOO.example.container.panel2.show, YAHOO.example.container.panel2, true);
YAHOO.util.Event.addListener("hide2", "click", YAHOO.example.container.panel2.hide, YAHOO.example.container.panel2, true);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment