By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,886 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Help with YUI needed - onContentReady and onDOMready

P: 4
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.html
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:
Expand|Select|Wrap|Line Numbers
  1. <div id="topmenu"></div>
  2. <script type="text/javascript">
  3. YAHOO.util.Event.onContentReady("topmenu",alert("contentready"));
Then the slider is never created.
Jul 31 '08 #1
Share this Question
Share on Google+
8 Replies


P: 4
Whoops, missed the </script> tag.
Expand|Select|Wrap|Line Numbers
  1. <div id="topmenu"></div>
  2. <script type="text/javascript">
  3. YAHOO.util.Event.onContentReady("topmenu",alert("contentready"));
  4. </script>
Jul 31 '08 #2

acoder
Expert Mod 15k+
P: 16,027
According to this page, you can use them together.
Jul 31 '08 #3

P: 4
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.

http://www12.brinkster.com/smileyface/1.htm
Jul 31 '08 #4

acoder
Expert Mod 15k+
P: 16,027
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.
Jul 31 '08 #5

P: 4
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.
http://www12.brinkster.com/smileyface/2.htm

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

acoder
Expert Mod 15k+
P: 16,027
In Firebug, it shows this error:
Expand|Select|Wrap|Line Numbers
  1. this.baselinePos is undefined
  2. if (newPos[0] != this.baselinePos[0] || newPos[1] != this.baselinePos[1]) {
  3. http://www12.brinkster.com/smileyface/slider-debug.js
  4. Line 779
  5.  
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.
Aug 1 '08 #7

P: 1
I am facing similar problem.
Does anyone know solution for this?
May 29 '09 #8

acoder
Expert Mod 15k+
P: 16,027
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.
May 29 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.