I'm writing a script to generate a control panel form an XML file and
I'm having trouble when attempting to attach events using
Event.observer.

An example node in my XML file looks like this:

<control ... >
<function action="click" do="doSomething" />
</control>

where "click" is the event and "doSomething" is the name of a
javascript function I have defined elsewhere.

My javascript looks something like this (the control nodes have already
been appended to the DOM as <a href..>'s):

var controls = $A(XML.getElementsByTagName("control"));
controls.each(function(node) {
                        var nFunctions = 
$A(node.getElementsByTagName("function"));
                        nFunctions.each(function(fun){
Event.observe(node.getAttribute("id"),fun.getAttribute("action"),fun.getAttribute("do"))
                        });
                });

I know the problem is with the last argument in Event.observe because
if I change the last argument to an anonymous function it works. It
also works if I change the last argument so that it is the name of the
function. These both work:

Anonymous function:
Event.observe(node.getAttribute("id"),fun.getAttribute("action"),function(e){alert(e);})

Name of function:
Event.observe(node.getAttribute("id"),fun.getAttribute("action"),doSomething)

This is the error I'm getting:
[Exception... "Could not convert JavaScript argument" nsresult:
"0x80570009
(NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame::
http://.../prototype.js :: anonymous :: line 1969" data: no]

Any help greatly appreciated. Thanks!

.
James


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Ruby on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to