【发布时间】:2014-04-16 10:36:48
【问题描述】:
最近我注意到在使用选择小部件 (CQ.form.Selection) 时 selectionchanged 事件会触发两次。当我从下拉列表中选择某个值时,selectionchanged 被触发一次,并且在选择完成后(即 onblur)从选择小部件中失去焦点时再次触发。
以下是对话框的结构。
<dialog jcr:primaryType="cq:Dialog" title="Test Component" xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<title jcr:primaryType="cq:Widget" fieldLabel="Selection" name="./sel" type="select" xtype="selection">
<listeners jcr:primaryType="nt:unstructured" selectionchanged="function(comp, val, isChecked) {console.log("selected");}"/>
<options jcr:primaryType="cq:WidgetCollection">
<opt1 jcr:primaryType="nt:unstructured" text="Option 1" value="1"/>
<opt2 jcr:primaryType="nt:unstructured" text="Option 2" value="2"/>
<opt3 jcr:primaryType="nt:unstructured" text="Option 3" value="3"/>
</options>
</title>
<link jcr:primaryType="cq:Widget" fieldLabel="Some Text" name="./text" xtype="textfield"/>
</items>
</dialog>
此问题仅在选择类型选择或 combobox 而不是复选框和收音机时才会观察到此问题。
我执行错了吗?这种行为正常吗?如何确保 selectionchanged 事件只触发一次?
提前致谢!
P.S:我使用的是 CQ 5.5,不确定在最新版本中此行为是否相同。
【问题讨论】: