¿Cómo puedo llamar a código JavaScript desde una acción de XForms?

I'm trying to call a javascript on a button click in XForm. Seems to be an easy task but... I've programmed everything as it is described aquí and have this added to my xml :

<xforms:trigger>
    <xforms:label>Increment foo with JavaScript</xforms:label>
    <xxforms:script ev:event="DOMActivate">
        alert("Test!")
    </xxforms:script>
</xforms:trigger>

But I get this error wher the page has loaded :

Fatal error: The prefix "ev" for attribute "ev:event" associated with an element type "xxforms:script" is not bound

Did I miss some thing?

preguntado el 09 de marzo de 12 a las 15:03

Agregar xmlns:ev="http://www.w3.org/2001/xml-events" to the root element of your document.. -

1 Respuestas

This means that the namespace prefix ev no es visible desde el <xxforms:script> elemento.

As @grtjn mentions in his comment, you have to add the proper XML namespace declaration. For example at the top of your document:

<xhtml:html
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:ev = "http://www.w3.org/2001/xml-events"
    xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
    <xhtml:head>
        ...

Note that in recent builds of Orbeon Forms, the prefix on event attributes is now optional, so you can write things like:

<xxforms:script event="DOMActivate">

But this might not be supported by other implementations.

respondido 09 mar '12, 16:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.