In a form, when user clicks a button , it will show a popup - in which i will take a input from the user - which should of ID type (http://books.xmlschemata.org/relaxng/ch19-77151.html).
When the user clicks on save- it will dispatch an event, which will add the taken input from the popup to the instance in the form if its of ID type.
I am not sure how to do it?
I have tried using bind and submit- that is i don't have any endpoint to post to- so when the error is not of type validation-error i am modifying the required instance.
But this does send an unnecessary post request- which i want to avoid.
The method i tried which is sending unnecessary POST request:
<xf:submission id="save-step" method="post" replace="none" ref="instance('addId')" >
<xf:action ev:event="xforms-submit-error" if="event('error-type')!='validation-error'">
<xf:insert ev:event="DOMActivate" nodeset="instance('addId')/step" at="last()" position="after" origin="instance('addStepId')/step"/>
<xf:dispatch ev:event="DOMActivate" name="popup-action-close" targetid="ModelId" />
</xf:action>
</xf:submission>
<xf:bind nodeset="instance('addStepId')/step/name" type="xsd:ID" constraint=" (count(instance('addId')/step/name[.=instance('addStepId')/step/name]) =0)" required="true()"/>
I want it to be done without submission like this:
<xf:action ev:event="save-step" >
<xf:insert nodeset="instance('addId')/step" at="last()" position="after" origin="instance('addStepId')/step" />
<xf:dispatch name="popup-action-close" targetid="ModelId" />
</xf:action>
<xf:bind id="checkStepName" nodeset="instance('addStepId')/step/name" type="xsd:ID" constraint=" (count(instance('addId')/step/name[.=instance('addStepId')/step/name]) =0)" required="true()"/>
But i am not sure how to attach xform bind to the xform action!
Bindings cannot be attached to actions: during action execution, bindings are not re-evaluated.
All bindings are re-evaluated, according to dependencies, after action execution.
In some very specific situations, there is a need for recalculating, refreshing or rebuilding within a sequence of actions. That's why xforms:recalculate, xforms:revalidate, xforms:refresh and xforms:rebuild actions have been specified.