<xxf:script>
/ <xf:action>
, you can also use the javascript:
protocol from the <xf:load>
action to run scripts:resource
attribute allows you to pass parameters from XForms to JavaScript, although you have to be careful to properly escape values.<xxf:param>
attribute of scripting actions.ORBEON.xforms.Document
ORBEON.xforms.Events.orbeonLoadedEvent
ORBEON.xforms.Events.errorEvent
ORBEON.jQuery
exposes the version of jQuery used by Orbeon Forms.String
or HTMLElement
toString()
setValue()
only).HTMLElement
xforms-form
is used.var value = ORBEON.xforms.Document.getValue(myControl)
.ORBEON.xforms.Document.setValue(myControl, "42")
. Setting the value with JavaScript is equivalent to changing the value of the control in the browser. This will trigger the recalculation of the instances, and the dispatch of the xforms-value-changed
event. More formally, the Value Change sequence of events occurs.getValue()
and setValue()
:myControl
in the above example) can either be:<foo>
and <bar>
, where <bar>
is a copy of <foo>
, implemented with a calculate MIP.<foo>
, and the output control is bound to <bar>
. When activated, the trigger executes JavaScript with the <xxf:script>
action. It increments the value of the input control bound to <foo>
. When this happens the value displayed by the output control bound to <bar>
is incremented as well, as <bar>
is a copy of <foo>
.first-name
, the XForms id for that field will be first-name-control
. Also, because your field is inside other containers, for instance a section, the id in the HTML for that field will have some prefix. Consequently, when using getValue()
and setValue()
described above, you'll want to write code along those lines:$=
CSS selector to get the element in the DOM whose id ends with first-name-control
.<fr:dropdown>
AKA <xf:select1 appearance="dropdown">
are compound controls: they are built out of other controls and do not directly export a value to JavaScript..xforms-select1
control:String
or HTMLElement
HTMLElement
xforms-form
is used.switch
/case
or dialog
.ORBEON.xforms.Document.dispatchEvent()
. The function takes a single parameter which is an object with properties as defined in the table below. Calling the function with several parameters in order listed in the table below is supported as a deprecated alternative for backward compatibility.dispatchEvent()
with a target id and event name, as in:do-something
event on the XForms model:<xf:model>
, <xf:instance>
, or <xf:submission>
.xforms-form
is used.false
the event is sent to the XForms server right away. When true
the event is sent after a small delay, giving the opportunity for other events that would occur during that time span to be aggregated with the current event.true
, errors happening while the event is dispatched to the server are ignored. This is in particular useful when you are using a JavaScript timer (e.g. window.setInterval()
) that runs a JavaScript function on a regular interval to dispatch an event to the server, maybe to have part of the UI updated. In some cases, you might not want to alert the user when a there is a maybe temporary communication error while the event is being dispatched to the server. In those cases, you call dispatchEvent()
with ignoreErrors
set to true
.bubbles
cancelable
DOMActivate
, DOMFocusIn
, DOMFocusOut
, and keypress
. Furthermore, these events can only be dispatched to relevant and non-readonly XForms controls. In order to enable dispatching of custom events, you must first add the xxf:external-events
attribute on the first <xf:model>
element, for example:acme-super-event
and acme-famous-event
to any relevant and non-readonly XForms controls, or to any model object supporting event handlers. Note that you can only enable custom events, but you cannot enable standard XForms or DOM events in addition to DOMActivate
, DOMFocusIn
and DOMFocusOut
.xxf:external-events
attribute:properties
parameter is a JSON object:event()
function. With the event dispatched above, in the handler for my-event
on my-target
, calling event('p1')
will return the string 'v1'
.dispatchEvent()
with a single object parameter; it isn't supported when calling it with multiple parameters.ORBEON.xforms.Events.orbeonLoadedEvent
fires when the form is fully loaded and initialized.orbeonLoadedEvent
, write:DOMContentLoaded
(similar to jQuery's "ready"). When this event fires, the global ORBEON
object exists.ORBEON.xforms.Events.errorEvent
fires when the JavaScript code catches an error.errorEvent
are as follows:errorEvent
), which most likely you don't need to know about if that listener is explicitly registered to this event.eventData
, inside your listener you can access:eventData.title
– A string describing the issue.eventData.details
– A string containing HTML with more information about the error, including:orbeonLoadedEvent
, you'll need to implement your listener in a named function, say myListener
: