Loading ...
Sorry, an error occurred while loading the content.

6230RE: [ydn-javascript] Container requires existing div

Expand Messages
  • Steven Peterson
    Nov 1, 2006
    • 0 Attachment

      Container doesn’t require an existing DIV. The DIV is created dynamically on render as long as you specify where it should be placed:

       

      var noteContainer = new YAHOO.widget.Panel('addNoteContainer', { /* args here */ } ) ;

      noteContainer.render(document.body);

       

      Furthermore, your Panel must use a DIV. A SPAN is not supported. If you’re having specific trouble with building a Panel dynamically, let me know what’s the issue is and I’d be more than happy to take a look at it. Also, keep in mind that IE won’t like it if you try to render the Panel into the body before it’s fully formed (i.e. window.load), so you should either render the Panel to an element that you know is already in the DOM, or render it to the body after the window has loaded.

       

      Steven Peterson

      Web Developer, Platform Engineering

      Yahoo!

       

      From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of xurizaemon
      Sent: Monday, October 02, 2006 5:29 PM
      To: ydn-javascript@yahoogroups.com
      Subject: [ydn-javascript] Container requires existing div

       

      I'm using the YUI Panel to insert a little "note" form for adding
      notes to an event. From my testing so far, to get Panel to work well
      requires that there be an existing <div> or <span> in the page and to
      refer to its ID.

      Because I didn't want to pepper the page with an empty <span> until it
      was required, I'm using this code before the Panel creation:

      // ensure we have an addNoteContainer div to play with
      if ( !YAHOO.util.Dom.get('addNoteContainer') ) {
      var addNoteContainer = document.createElement('span') ;
      addNoteContainer.id = 'addNoteContainer' ;
      document.getElementsByTagName('body')[0].appendChild(addNoteContainer) ;
      }
      // make my panel
      var noteContainer = new YAHOO.widget.Panel('addNoteContainer',
      { /* args here */ } ) ;

      This ensures that I have a span with ID of "addNoteContainer" to fool
      around with. That's fine.

      My questions:
      1) Do I need to be doing this, or should Panel work if you feed it a
      'blank' ID?
      2) How can this code be 'better' - or just more YUIish?

      Cheers

      0000

      A couple of observations on Yahoo! Groups UI from making this post:

      1) +1 for a design pattern which says, "If any password field has
      focus, don't switch focus to a plaintext field as a result of page
      load etc, even when you really think it will help".

      2) Switching to 'richtext' editor in Yahoo! groups doesn't preserve
      the message content. That's fine, if you mod+A,mod+C before hitting
      the button.

    • Show all 2 messages in this topic