Thursday, 15 January 2015

Accessing the XForms/XSLTForms model instances with javascript -



Accessing the XForms/XSLTForms model instances with javascript -

i'm trying -uncessfully- access instances of model, in order add together info via js. know can adding trigger insert action, i'm working canvas need same via js.

i added onload function triggered when document body loaded. tryed instance "instance" action of xforms, not recognized function.

var instanceelement = instance('application'); console.log( instanceelement);

i tryed instance with:

document.getelementbyid(id);

but returned null. so, how can access model? in advance!

calling straight xsltforms code can bring mantainance problems, because object names change.

a thought creating wrappers functions encapsulate mutual xsltforms tasks.

here of them can use:

function xf_getinstance(modelid, instanceid) { var model = window.document.getelementbyid(modelid); var doc = model.getinstancedocument(instanceid); homecoming doc; } function xf_getnode(context, path) { homecoming xsltforms_browser.selectsinglenode(path, context); } function xf_changenode(node, value) { xsltforms_globals.openaction("xsltforms_change"); xsltforms_browser.setvalue(node, value || ""); document.getelementbyid(xsltforms_browser.getmeta(node.ownerdocument.documentelement, "model")).xfelement.addchange(node); xsltforms_browser.debugconsole.write("setvalue " + node.nodename + " = " + value); xsltforms_globals.closeaction("xsltforms_change"); } function xf_fireevent(targetid, eventname) { xsltforms_globals.openaction("xsltforms_dispatch"); xsltforms_xmlevents.dispatch(document.getelementbyid(targetid), eventname); xsltforms_globals.closeaction("xsltforms_dispatch"); }

xforms xsltforms

No comments:

Post a Comment