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

Re: [ydn-javascript] Problem in IE with Panel (SOLUTION)

Expand Messages
  • Eric S
    ... I think I see where the failure to communicate is. The function you re calling is not the issue. That is to say, this issue is related to what you re
    Message 1 of 7 , Oct 27, 2006
      sergio.cinos@... (IMAP) wrote:
      > Dear Dav,
      >
      > humm... It was a typo. That 'renderPanel' is just an example. In my
      > code there is another function name, ending in () :) That function
      > does a lot of things (like drawing a table, drawing a menu...) a lot
      > of them regarding writing in document.body, and everyone works ok.
      > Except panel.render() :)
      >

      I think I see where the failure to communicate is. The function you're
      calling is not the issue. That is to say, this issue is related to what
      you're passing to addListener, not how you're calling panel.render. By
      using YAHOO.util.Event.addListener(window, "load", whatever()), you're
      saying to pass addListener a pointer to window, the string "load", and
      the return value of the function whatever. This means that whatever
      gets called before addListener, and the return value gets passed to
      addListener. On the other hand, by using
      YAHOO.util.Event.addListener(window, "load", whatever), you're passing
      addListener a reference to the whatever function as the third parameter,
      so the function whatever gets called when the event fires.

      Now, panel.render does not work well, if at all, if the DOM of the body
      and its top level children haven't been loaded, so if it's being called
      when you set up a listener for the body or window, the DOM probably
      isn't loaded yet and it won't work. I don't know about the other things
      you're doing, but it sounds like they don't require the DOM to be loaded
      when called. Whether it's called directly, or by a different function,
      is beside the point, it's purely a matter of when the call is made
      chronologically.

      On the other hand, using <body onload="whatever()"> works, because the
      string you're assigning to onload doesn't get evaluated until the load
      event is triggered, at which time the DOM is loaded by definition of the
      load event.

      Hope this clears up how this works a little bit better. Every time I
      learn a new programming language, how to pass a function by reference
      rather than running it and returning a value is always something I look
      up, because it can be a confusing issue if you get it wrong.
    Your message has been successfully submitted and would be delivered to recipients shortly.