Help with YUI needed - onContentReady and onDOMready

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Philklc
    New Member
    • Jul 2008
    • 4

    Help with YUI needed - onContentReady and onDOMready

    I'm working on a website which will use the Slider control from YUI. It runs when onDOMReady is executed.

    But my website has a global header that must be put on all pages, which has a site navigation menu which uses onContentReady. It caused the Slider control to stop working. And since I'm just an intern, I do not have the permission to change it. I need a way to make onContentReady and onDOMReady co-exist. Can anyone help?

    http://developer.yahoo .com/yui/examples/slider/slider-simple_clean.ht ml
    The slider is created and its value is set to 20 after the page's DOM has finished loading.
    Copy their source code, and add these right after the <body> tag:
    Code:
    <div id="topmenu"></div>
    <script type="text/javascript">
    YAHOO.util.Event.onContentReady("topmenu",alert("contentready"));
    Then the slider is never created.
  • Philklc
    New Member
    • Jul 2008
    • 4

    #2
    Whoops, missed the </script> tag.
    Code:
    <div id="topmenu"></div>
    <script type="text/javascript">
    YAHOO.util.Event.onContentReady("topmenu",alert("contentready"));
    </script>

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      According to this page, you can use them together.

      Comment

      • Philklc
        New Member
        • Jul 2008
        • 4

        #4
        Originally posted by acoder
        According to this page, you can use them together.
        I made these pages out of their example pages. As you can see, the page which both onContentReady and onDOMReady exist, the onDOMReady event never gets fired, the slider never gets initalized... not in Firefox 3, not in IE7, not sure about other browsers.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          I haven't tested so I'm not sure if it'll make a difference, but instead of an alert, try using the YUI logger to log a message onContentReady.

          Comment

          • Philklc
            New Member
            • Jul 2008
            • 4

            #6
            Originally posted by acoder
            I haven't tested so I'm not sure if it'll make a difference, but instead of an alert, try using the YUI logger to log a message onContentReady.
            Thanks for the suggestion.


            Alright, so it seems that onDOMReady does get fired, but the slider doesn't work... any ideas?

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              In Firebug, it shows this error:
              Code:
              this.baselinePos is undefined
              if (newPos[0] != this.baselinePos[0] || newPos[1] != this.baselinePos[1]) {
              http://www12.brinkster.com/smileyface/slider-debug.js
              Line 779
              when trying to drag the slider. It may be a bug in YUI, though I'm not sure. It'll probably be best to ask a YUI expert.

              Comment

              • gauravgupta
                New Member
                • May 2009
                • 1

                #8
                I am facing similar problem.
                Does anyone know solution for this?

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  Are you having the same problem with the slider? Post your code.

                  When using libraries, it's always a good idea, if possible, to upgrade to the latest stable version to get rid of possible bugs.

                  Comment

                  Working...