From: Micah D. <Mic...@ma...> - 2009-06-17 05:15:28
Alain and friends,
Within the JavaScript of an app, I need to activate a <trigger> of a
certain id, exactly as if someone had clicked a button.
Is there an easy way to do this?
-m
From: COUTHURES A. <ala...@ag...> - 2009-06-17 05:55:41
Hi Micah,
Here is an example of Javascript Trigger Activation :
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
>
<head>
<title>Javascript Trigger Activation Example</title>
<xf:model/>
</head>
<body onload="$('console').style.display = 'block';">
<xf:trigger>
<xf:label>Button 1</xf:label>
<xf:message level="modal" ev:event="DOMActivate">Hello from
Button 1</xf:message>
<xf:load ev:event="DOMActivate"
resource="javascript:$('button2').xfElement.click()"/>
</xf:trigger>
<xf:trigger id="button2">
<xf:label>Button 2</xf:label>
<xf:message level="modal" ev:event="DOMActivate">Hello from
Button 2</xf:message>
</xf:trigger>
</body>
</html>
I have tested it with the committed work version in the SVN repository.
I'm not sure it would also work with the beta version for many reasons...
Hope it helps.
-Alain