我需要在CQ5对话框中验证用户提供的输入(页面组件 - 在侧踢中单击页面属性时打开).某些字段没有vtype属性.我打算在对话框下的侦听器节点中使用对话框的beforesubmit事件.由于某种原因,不会调用beforesubmit事件的函数.它的行为就像事件根本没有添加一样.我尝试将afterrender事件添加到同一个侦听器节点并且它可以工作.以下摘自我的dialog.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.orgjcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
title=""
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
</items>
<listeners
jcr:primaryType="nt:unstructured"
afterrender="function(dialog){alert(dialog);}"
beforesubmit="function(dialog){alert(dialog);}"/>
</jcr:root>
Run Code Online (Sandbox Code Playgroud)
请帮我弄清楚如何按下对话框上的OK按钮调用一个函数,如果验证失败则取消提交.提前致谢.
我指的是以下链接上的代码:
这是因为对话框的xtype是" tabpanel ",而tabpanel 没有 beforesubmit事件.
如果验证失败,请将xtype更改为" dialog "并在beforesubmit处理程序中返回false.这样可以防止提交对话框.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.orgjcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
title="" xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection"></items>
<listeners jcr:primaryType="nt:unstructured"
beforesubmit="function(dialog){
if(<<!valid>>){
return false;
}
}" />
</jcr:root>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8258 次 |
| 最近记录: |