tags:

views:

62

answers:

3

I am new to YUI. Just trying to get a most basic functioning example working on my site.

Here is the code:

    <button id="mytest">test</button>

    <script type="text/javascript">
    var helloWorld = function(e) {
            alert("Hello World!");
    }
    </script>


    <script type="text/javascript">
    alert('xx');
    YAHOO.util.Event.addListener("mytest", "click", helloWorld);
    alert('x2');
    </script>

The xx alert shows, but the x2 alert never does. And, clicking on the button does not fire the HelloWorld function.

I have the necessary include files:

    <!-- Required CSS -->
    <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/progressbar/assets/skins/sam/progressbar.css"&gt;

    <!-- Dependency source file -->
    <script src = "http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom.event.js" ></script>
    <script src = "http://yui.yahooapis.com/2.8.1/build/element/element-min.js" ></script>
    <!-- Optional dependency source file -->
    <script src="http://yui.yahooapis.com/2.8.1/build/animation/animation-min.js" type="text/javascript"></script>

    <!-- ProgressBar source file -->
    <script src = "http://yui.yahooapis.com/2.8.1/build/progressbar/progressbar-min.js" ></script>
A: 

Believe I found it. Or at least I was able to find other examples which worked. But in my case I believe the problem is the js files I was referencing in fact did not exist. Namely this file:

http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom.event.js

M Schenkel
For future reference, learn to use and love the Firebug extension for Firefox. 404s and other errors are shown helpfully in red in the Net tab. :)
AKX
+1  A: 

you should be sure the js files are included on you html files,the code your write is write!

janwen
Yes - but I saw "suggestions" from yahoo themself that it is ok to reference the files from their site.
M Schenkel
A: 

sure, it is yahoo dash dom DASH event, not yahoo dash dom DOT event

Satyam