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

Re: [ydn-javascript] javascript include semantics

Expand Messages
  • Eric Miraglia
    Alan, I m glad you got it working -- it makes perfect sense that including both yahoo.js and yahoo-dom-event.js would have caused the problem. You should be
    Message 1 of 7 , Dec 29, 2006
    • 0 Attachment
      Alan,

      I'm glad you got it working -- it makes perfect sense that including both yahoo.js and yahoo-dom-event.js would have caused the problem.  You should be able to use the solution I suggested after loading yahoo-dom-event.js, moving the local YAHOO variable to window.YAHOO after you eval yahoo-dom-event.js.

      Re: Purposeful Sandboxing
      Note what I said in my earlier post: When you include yahoo.js as script include, it does create YAHOO in the global namespace.  The expectation is that most users will want that and will implement in that fashion.  But by using var YAHOO = {} instead of window.yahoo = {}, the implementer is given the option of scoping the entire YUI library locally.  This would, in theory, permit someone to run multiple versions of the library on the same page, for example.  Although we're not advocating that usage, we believe we shouldn't preclude it, either.  Hence the change in 0.12.

      Regards,
      Eric

      ______________________________________________
      Eric Miraglia
      Yahoo! User Interface Library



      On Dec 29, 2006, at 10:12 AM, Alan Pinstein wrote:

      This indeed was the problem... yahoo-dom-event.js is the problem. It
      was not eval-safe either...

      I didn't realize initially that it replaced yahoo.js as well, so
      until just moments ago I was using BOTH yahoo.js (which I corrected
      for scope) and yahoo-dom-event.js (which I had not corrected) and
      thus yahoo-dom-event was adding the event functions to the *local*
      YAHOO rather than the *global* one that was set up in yahoo.js.

      Thanks for walking me through this!

      Also, please do explain the purposeful sandboxing; I am curious about
      the advantages.

      Thanks,

      Alan

      On Dec 29, 2006, at 9:58 AM, Alan Pinstein wrote:

      >> When I eval the current yahoo.js (v0.12.1) and then make
      >> window.YAHOO=YAHOO within that function, I am subsequently able to
      >> load event.js via XHR, eval it as is, and use it from the global
      >> scope. In other words, evaling event.js populates the global
      >> window.YAHOO.util.Event object as desired; I can then, anywhere on
      >> the page, call YAHOO.util.Event.addListener(), for example. Is
      >> there a public url where we could look at your example where this
      >> fails? (I'm testing in FF2, primarily; is it only in IE that you
      >> see this fail?)
      >
      > Ah, you know what? I am trying the new yahoo-dom-event.js. That one
      > didn't work. I'll try the event.js and see if that works.


    Your message has been successfully submitted and would be delivered to recipients shortly.