> This is the piece of code that don't work:
> connect('red', 'onclick', swapImg);
> the "src has no properties" is the error but when I try to use:
> connect('window, 'onload', swapImg);
> it work fine.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <title>Mock</title>
> <script type="text/javascript" src="MochiKit.js"></script>
> <script type="text/javascript">
>
> var swapImg = function() {
> finalimg = IMG({'src': 'logo.png'});
> swapDOM(selector, finalimg);
> };
>
> connect('red', 'onclick', swapImg);
>
> </script>
> </head>
> <body>
> <div id="selector">
> <img src="adverts/110x26-5kb-Hostedby-colored.gif" />
> </div>
>
> <a href="#" id="red">red</a>
> </body>
> </html>
That is because 'red' doesn't exist when the interpreter gets to your line
"connect('red', 'onclick', swapImg);" - however, 'window' does. Change your
script section to look like this:
<script type="text/javascript">
var swapImg = function() {
finalimg = IMG({'src': 'logo.png'});
swapDOM(selector, finalimg);
};
connect(window, "onload", function() {
connect('red', 'onclick', swapImg);
});
</script>
I believe that will fix your problems.
Jason Bunting
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.3/446 - Release Date: 9/12/2006
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---