Catching save event in Form Builder

人盡茶涼 提交于 2019-12-13 06:53:20

问题


I would like to send submission after form has been saved in Form Builder, I was trying something like this at first (in my XBL file):

<xf:action ev:event="fr-data-save-done" ev:observer="fr-form-model">
    <xf:message event="#all" level="modal">Saved</xf:message>
    <xf:send submission="my-submission" ev:event="#all"/>
</xf:action>

The code above is placed in XBL file between xbl:template, outside xbl:model (though I tried to put it inside xbl:model with no luck). Unfortunately it's not working, after I save my form in Form Builder message is not shown. Anyone got idea why it's not working?


回答1:


You could place by hand an event handler like this:

<foo:bar id="my-component-id" bind="my-bind">
    <xf:dispatch
        event="fr-data-save-done"
        observer="fr-form-model"
        name="my-custom-event"
        targetid="my-component-id"/>
</foo:bar>

The handler doesn't have to be within the element:

<foo:bar id="my-component-id" bind="my-bind"/>
<xf:dispatch
    event="fr-data-save-done"
    observer="fr-form-model"
    name="my-custom-event"
    targetid="my-component-id"/>

And inside the XBL component:

<xbl:binding id="my-binding-id" element="foo:bar">
    <xbl:handlers>
        <xbl:handler event="my-custom-event" phase="target">
            ... XForms actions here ...
        </xbl:handler>
    </xbl:handlers>
    ...
</xbl:binding>


来源:https://stackoverflow.com/questions/27608979/catching-save-event-in-form-builder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!