Posted by
Joel Oates on
Sep 09, 2019; 2:04pm
URL: https://discuss.orbeon.com/XBL-Companion-Javascript-Multiple-Custom-Function-Triggers-tp4664683.html
Hello All!
I am having an issue with the implementation of my own companion java-script
class, the issue is around calling my own custom functions declared inside
the javascript but I cannot call separate custom functions from within my
XBL.
I have my class declared and all working with the following. (Snippet)
(function() {
// Optional shortcut to jQuery
var $ = ORBEON.jQuery;
// Register your companion class by its binding name
ORBEON.xforms.XBL.declareCompanion("workflow|pdf-viewer", {
// Your custom data goes here
init: function() {
},
// Your custom functions go here
displayPDF: function(val) {
... Do stuff ...
});
},
onNextPage: function () {
... Do Stuff ...
},
onPrevPage: function () {
... Do Stuff ...
},
})
})();
Now I have my XBL component declared with the following...
<xbl:xbl {Name Spaces}>
<xbl:script src="/xbl/workflow/pdf-viewer/pdf-viewer.js" />
<xbl:binding id="workflow-pdf-viewer"
element="workflow|pdf-viewer"
xxbl:mode="lhha binding javascript-lifecycle">
<metadata xmlns="
http://orbeon.org/oxf/xml/form-builder">
<display-name lang="en">PDF Viewer</display-name>
<icon lang="en">
</icon>
<template>
<workflow:pdf-viewer id="" ref="" xmlns="">
<xf:label ref="" />
<xf:hint ref="" />
<xf:help ref="" />
<xf:alert ref="$fr-resources/detail/labels/alert" />
</workflow:pdf-viewer>
</template>
</metadata>
<xbl:resources>
<xbl:style src="" />
</xbl:resources>
<xbl:template>
<xf:model id="local-model">
<xf:instance>
<test></test>
</xf:instance>
<xf:bind id="test-bind" name="test" ref="instance()"/>
</xf:model>
<xf:group id="workflow-component-group" model="local-model">
... My Triggers and Actions are here ....
</xf:group>
</xbl:template>
</xbl:binding>
</xbl:xbl>
Now I can call my displayPDF function with the following (from inside the
<xf:group> )
<xf:trigger>
<xf:label value="'Display PDF'"/>
<xf:action type="javascript" ev:event="DOMActivate"
observer="workflow-pdf-viewer">
<xf:param
name="testValue"
value="bind('test-bind')"/>
<xf:body>
ORBEON.xforms.XBL.instanceForControl(this).displayPDF(testValue);
</xf:body>
</xf:action>
</xf:trigger>
This works! However if I want another trigger to call a different function
on the java script, it will trigger ALL the javascript actions (As they all
have the same observer (but I need them to, to have the javasctipt to map
correctly))
Example:
<xf:trigger>
<xf:label value="'Display PDF'"/>
<xf:action type="javascript" ev:event="DOMActivate"
observer="workflow-component-group">
<xf:param
name="testValue"
value="bind('test-bind')"/>
<xf:body>
ORBEON.xforms.XBL.instanceForControl(this).displayPDF(testValue);
</xf:body>
</xf:action>
</xf:trigger>
<xf:trigger class="next">
<xf:label value="'Next Page'"/>
<xf:action type="javascript" event="DOMActivate"
observer="workflow-component-group">
<xf:body>
ORBEON.xforms.XBL.instanceForControl(this).onNextPage();
</xf:body>
</xf:action>
</xf:trigger>
Is there a way I can call multiple custom functions on the javascript using
triggers?
I believe the main cause is because all my triggers have the same observers
on the actions, and once the DOMAcitvate event is triggered on one, the
other events also are fired! however I need the Observer's to be the same as
its the only way the javascript maps correctly to the action. Is there
another way of getting this mapping working without using the same
observers?
Thanks for your time, Sorry for the lengthy one, Little stuck at the moment.
Cheers,
Joel.
--
Sent from:
http://discuss.orbeon.com/--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
[hidden email].
To view this discussion on the web visit
https://groups.google.com/d/msgid/orbeon/1568037843565-0.post%40n4.nabble.com.