Ajax Bestiary: A Javascript Field Guide
 
Ajax Bestiary: A Javascript Field Guide
 
 

Build a YUI Panel from Content

Posted by Don Albrecht

After yesterday’s comment regarding my display:none / innerHTML hack on building a YUI panel.  I thought I’d quickly show you how to build a panel from markup without the display:none;

For a quick refresher, I recommend you read: http://www.ajaxbestiary.com/2007/09/19/building-a-form-in-a-modal-panel-with-yui/

Now, to achieve the same results we can do the following.

  1. Remove the display:none from the panel div
  2. Place the form into a <div class="bd"> tag
  3. Place the form header in a <div class="hd"> tag before the bd tag but inside of the panel div.
  4. If you’re going to add a footer, place it after the <div class="bd"> tag inside of a <div class="ft"> tag
  5. Replace the instantiation command with myPanel = new YAHOO.widget.Panel( "panelid"); where "panelid" is the id of the div wrapping the various panel containers. 
  6. You now have a panel to render, show, hide & modify based on your page content.

I apologize for the shotgun approach to this post, but I thought it was a handy correction to get out there.

Related Posts


Leave a Reply