Hello,

I'm just trying to do a really simple thing by setting an event on an
element with connect() and then changing that element's html with
innerHTML. But I'm not sure how to properly pass parameters through
connect() to my function. I can see with MochiKit.Logging that the
values ARE being passed but because of the error I'm getting the
connect() function does not execute correctly.

Here is my HTML:

<!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>Test 6</title>

<script type="text/javascript"
src="../mochi131/lib/MochiKit/MochiKit.js"></script>

<script>
        function change_html (id, new_html)
        {
                e = MochiKit.DOM.getElement(id);

                e.innerHTML = new_html;

                MochiKit.Logging.log('i was clicked');
        }

        function run_mystuff ()
        {
********                connect('target1', 'onclick', change_html);
        }

        MochiKit.DOM.addLoadEvent(run_mystuff);
</script>

</head>
<body>

<div id="target1">
asdf
</div>

<div id="target2">
</div>

</body>
</html>

-------------

If I change the line marked with stars to...

connect('target1', 'onclick', change_html('target1', 'new html'));

...I get an error that says "'objOrFunc' must be a function if
'funcOrStr' is not given'.

If I hard code the values everything works fine. What do I need to
change?



Thanks,
Chris.


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