Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Handler Orbeon xforms window.onbeforeunload处理程序_Handler_Orbeon_Onbeforeunload_Xforms - Fatal编程技术网

Handler Orbeon xforms window.onbeforeunload处理程序

Handler Orbeon xforms window.onbeforeunload处理程序,handler,orbeon,onbeforeunload,xforms,Handler,Orbeon,Onbeforeunload,Xforms,当有人从xform中单击时,我希望实现自定义警报对话框(不是浏览器使用的对话框)的外观,该对话框向用户发出警报,并让用户有机会选择是保留还是离开xforms(取消/确定按钮) 以下是我的诀窍: <xf:action ev:event="xforms-ready"> <xxf:script> window.onbeforeunload = function() { return ORBEON.xforms.Document.dispatchEvent('fr-form-

当有人从xform中单击时,我希望实现自定义警报对话框(不是浏览器使用的对话框)的外观,该对话框向用户发出警报,并让用户有机会选择是保留还是离开xforms(取消/确定按钮) 以下是我的诀窍:

<xf:action ev:event="xforms-ready">
<xxf:script>

window.onbeforeunload = function() {
return  ORBEON.xforms.Document.dispatchEvent('fr-form-model','clickout') 
                    } 
</xxf:script>
</xf:action>

window.onbeforeunload=函数(){
返回ORBEON.xforms.Document.dispatchEvent('fr-form-model','clickout')
} 
以下是我的模型和事件处理程序:

<xf:model id="fr-form-model" xxf:expose-xpath-types="true" xxf:external-events="clickout">

<xf:action ev:event="clickout">
<xf:dispatch target="cancel_dialog" name="fr-show"/>
</xf:action>

对话框显示正确,但不会停留在那里,让用户有机会选择要做什么。1-2秒后,Xform关闭,用户无法选择离开或停留。知道问题出在哪里吗

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。更新

<xf:output bind="data-bind" id="datastatus" />      
Thnx对于答案,至少有可能在默认对话框中使用自定义消息吗?(我希望信息是德语)

基于此,

我做了这个把戏:

<xxf:script ev:event="xforms-ready">
                window.onbeforeunload = function() {
                    if (ORBEON.xforms.Document.getValue('datastatus') == 'dirty')
                    return "Sie haben nicht gespeicherte Änderungen.";
                    }
            </xxf:script>

window.onbeforeunload=函数(){
if(ORBEON.xforms.Document.getValue('datastatus')=='dirty')
返回“您不在这里。”;
}
在模型的上面…:

(一)


(二)

xf:action ev:event=“xforms模型构造完成”>
清洁的
他认为:

 <xf:setvalue ev:event="xforms-value-changed" ref="xxf:instance('fr-persistence-instance')/data-status">dirty</xf:setvalue>
dirty

<xf:output bind="data-bind" id="datastatus" />      

在Ui中,我可以看到输出“datastatus”的值正确地从干净变为脏,但是window.onbeforeunload不起作用。(如果我退出表单,弹出窗口不会出现)。有什么想法吗?提前通知

上次更新。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 有一个取消按钮(退出表单),客户希望此按钮触发与windows.onbeforenull默认处理程序触发相同的对话框(如果有未保存的更改),我指的是浏览器显示的对话框

我试着做这样的事情:

<xf:trigger id="cancel-control" bind="cancel-bind">
                                <xf:label ref="$form-resources/cancel/label" />
                                <xf:action ev:event="DOMActivate"  >

                                    <xxf:script if="($calculationsDisabled eq false()) and ((xxf:instance('fr-persistence-instance')/data-status = 'dirty'))">
                                        function() {return "You may lose some unsaved changes.";}
                                    </xxf:script>

                                <xxf:script if="($calculationsDisabled eq true()) or ((xxf:instance('fr-persistence-instance')/data-status = 'clean'))">
                                window.parent.closeIframe();
                                </xxf:script>

                                </xf:action>

                            </xf:trigger>

函数(){return“您可能会丢失一些未保存的更改。”;}
window.parent.closeIframe();
但它也不起作用。请注意下面的自定义对话框方法:

<xf:trigger id="cancel-control" bind="cancel-bind">
                                    <xf:label ref="$form-resources/cancel/label" />
                                    <xf:action ev:event="DOMActivate">
                                        <xf:dispatch target="cancel_dialog" name="fr-show"
                                            if="($calculationsDisabled eq false()) and ((xxf:instance('fr-persistence-instance')/data-status = 'dirty'))" />
                                    </xf:action>

                                    <xf:action ev:event="DOMActivate" if="($calculationsDisabled eq true()) or ((xxf:instance('fr-persistence-instance')/data-status = 'clean'))"  >
                                        <xxf:script>window.parent.closeIframe();</xxf:script>
                                    </xf:action>
                                </xf:trigger>

window.parent.closeIframe();

工作正常,但客户不希望有两个不同的对话框窗口(浏览器的警报对话框和自定义的“取消对话框”)。再次提前Thnx。在这种情况下,您不能使用自己的对话框。这是因为,如果您返回的不是
null
未定义的
,浏览器将仅停止加载另一个页面,或关闭选项卡/窗口,并且在这种情况下,浏览器将向用户显示其自己的对话框。

@nigioCeid,同时您可以本地化Form Runner使用的“所有”资源,这是个例外。如果您只需要支持德语,我建议您更改
check dirty script.xhtml
中的文本。另外,我已经为此创建了,所以希望在该产品的未来版本中,这将为您实现开箱即用。最后一个问题:至少,我可以在退出按钮上弹出相同的浏览器对话框吗?请检查最后一个update@nigioCeid我不确定
window.parent.closeIframe()
在您的情况下做了什么,但您的意思是,询问用户是否确定要正确关闭窗口的标准浏览器对话框会显示出来。看来你什么都不需要做;只需调用
window.parent.closeIframe()
就可以了,不用担心自己会显示一个对话框,对吧?window.parent.closeIframe();这是我的退出/取消控制处理程序;默认浏览器警报对话框不会出现。只有在窗体外部单击时才会出现。明白了,父窗口中的
window.parent.closeIframe()
做了什么?只是确认一下,有问题的iframe就是其中加载了Orbeon Forms生成的表单,对吗?
<xf:trigger id="cancel-control" bind="cancel-bind">
                                    <xf:label ref="$form-resources/cancel/label" />
                                    <xf:action ev:event="DOMActivate">
                                        <xf:dispatch target="cancel_dialog" name="fr-show"
                                            if="($calculationsDisabled eq false()) and ((xxf:instance('fr-persistence-instance')/data-status = 'dirty'))" />
                                    </xf:action>

                                    <xf:action ev:event="DOMActivate" if="($calculationsDisabled eq true()) or ((xxf:instance('fr-persistence-instance')/data-status = 'clean'))"  >
                                        <xxf:script>window.parent.closeIframe();</xxf:script>
                                    </xf:action>
                                </xf:trigger>