- From: Mark Birbeck <mark.birbeck@x-port.net>
- Date: Mon, 3 Oct 2005 14:59:33 +0100
- To: "'Sergey Shebanin'" <splash@rulogic.ru>
- Cc: <www-forms@w3.org>
Hi Sergey, > In IE (FormsPlayer) I can catch only standard event (defined in W3C > Recommendation) with > <script for="object-id" event="xforms-event" type="text/javascript"> > But I still cann't catch any user defined events fired with > <xforms:dispatch .../> That's right. It's not a good technique to use, to be honest, since what's happening is we are mapping 'proper' DOM 2 Events as generated by our XForms processor into 'old-style' events as used by IE. In the case of <script> IE can only register for known events. What you can do instead, is to create a DOM 2 Events handler object and then set its handler object to point to a JavaScript function: var theListener = this.document.getFeature("Events.listener", "2.0"); theListener.handler = this.handleDOM2Event; function handleDOM2Event(evt) { ... } Once you have this handler object you can attach it to the correct target: oTarget.addEventListener("my-event", theListener, false); This all amounts to doing the same as Alex's suggestion, which was: document.addEventListener("xforms-refresh", function(){ jsfunc(); }, false); The reason for the difference is that the DOM 2 Events specification defines the second parameter to addEventListener() as being a listener object. However, most implementations allow a JavaScript function to be passed in this position, and although this is in ECMAScript bindings section of the spec, there is nowhere that we can find that says that there is some implicit cast going on. So until we resolve this we decided to create an explicit listener object, and then wire it up to point to the function you want. > Also when I call > document.getElementById('some-xforms-trigger').fireEvent('DOMActivate') > I see error message. > Can anybody explain how to interact XForms and JavaScript in IE > (FormsPlayer) As Alex says, you need to use the standard DOM 2 Events techniques: > Sending is likewise done with createEvent() and dispatchEvent(). and we have added stuff to the IE DOM so that you can use these standards. To illustrate, here's a snippet from one of the clock demos: <script type="text/javascript"> function fnSetTimeoutFrequency(nSecs) { setTimeout(fnTimeout, nSecs * 1000); } function fnTimeout() { var evt = document.createEvent("Event"); var oEvtList = document.getElementById("event-list"); evt.initEvent("my-timeout", false, false); oEvtList.dispatchEvent(evt); /* * Set the next timeout for one seconds time */ fnSetTimeoutFrequency(10); return; } </script> <xf:group id="event-list"> <xf:action ev:event="my-timeout"> <xf:setvalue ref="instance('i')/now" value="now()" /> </xf:action> </xf:group> Note that all of these techniques are only available to you on one of our XForms elements, since we are co-existing with the normal IE DOM. (By that I mean that 'oTarget' cannot be an HTML element.) Regards, Mark Mark Birbeck CEO x-port.net Ltd. e: Mark.Birbeck@x-port.net t: +44 (0) 20 7689 9232 w: http://www.formsPlayer.com/ b: http://internet-apps.blogspot.com/ Download our XForms processor from http://www.formsPlayer.com/
Received on Monday, 3 October 2005 14:00:19 UTC