On 10/12/06, Chris <[EMAIL PROTECTED]> wrote:
>
> Bob Ippolito wrote:
> > Yes, but you probably ought to be using MochiKit.Signal's connect
> > function for that instead...
>
> Hi Bob.
>
> I'm attempting to learn to use MochiKit.Signal and I'm stuck. The
> documentation for connect() says "src is the object that has the
> signal. You may pass in a string, in which case, it is interpreted as
> an id for an HTML element." According to that I *think* I'm assigning
> an onclick event to the div called 'test' that, when triggered, will
> execute the function called writelog(). But I get an error that says
> "src has no properties".
>
> Here is my HTML file:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> <head>
> <title></title>
>
> <script type="text/javascript"
> src="../mochi131/lib/MochiKit/MochiKit.js"></script>
>
> </head>
> <body>
>
> <script>
>
>         function writelog()
>         {
>                 log('hello');
>         }
>
>         logError('helllllo');
>
>         connect('test', 'onclick', writelog);
>
>         void(createLoggingPane(true));
>
> </script>
>
> <div id="test">
>         <p>
>                 Hi!
>         </p>
> </div>
>
> </body>
> </html>

Your script runs before the body is parsed, so the element doesn't
exist yet. You need to make sure it executes *after* the document is
parsed. Every single example uses addLoadEvent or connect(window,
'onload', ...) to do this.

> (Now for some questions.)
>
> 1. What does MochiKit consider to be a "property"?

That's a JavaScript error, not a MochiKit error. Properties are what
objects have. In Python they're called attributes. In general, "has no
properties" means you've got undefined or null where an object was
expected.

> 2. Does including MochiKit.js automatically include all the libraries
> in MochiKit? Is it more efficient to only include the libraries I need
> per page?

It includes all of the libraries that shipped with MochiKit 1.3.

> 3. Is there a FAQ somewhere?

No, but there's the wiki. Feel free to start a FAQ: http://trac.mochikit.com/

> 4. Why don't I need to access the functions with
> MochiKit.Signal.connect()? What if I create my own function later that
> overlaps a MochiKit function I am not aware of?

I don't understand this question.

-bob

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to