Skip to content

Instantly share code, notes, and snippets.

@ebruchez
Last active September 15, 2015 16:46
Show Gist options
  • Save ebruchez/f64812d6fa7cb44b2a47 to your computer and use it in GitHub Desktop.
Save ebruchez/f64812d6fa7cb44b2a47 to your computer and use it in GitHub Desktop.
_findControl: (controlIdOrElem, formElem) ->
[controlId, resolvedControl] =
if _.isString(controlIdOrElem)
controlId = controlIdOrElem
formId =
if _.isElement(formElem)
formElem.id
else
$(document.forms).filter('.xforms-form')[0].id
ns = ORBEON.xforms.Globals.ns[formId]
[controlId, document.getElementById(ns + controlId)]
else
[controlIdOrElem.id, controlIdOrElem]
if not resolvedControl?
throw "Cannot find control id #{controlId}"
if Controls.isInRepeatTemplate(resolvedControl)
throw 'Cannot set the value of a repeat template'
resolvedControl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment