重新初始化 xxforms-iteration-moved 上的 XBL 组件
我有一个 XBL 组件,它在 javascript 中创建一个复选框控件。值是在组件初始化期间在 javascript 中设置的。当不在重复内部使用时,组件运行良好,但当我尝试向上或向下移动行时,在内部重复 XBL 控件不会更改状态。
xxforms-iteration-moved 事件在移动的行上触发,但不会在此移动期间更改位置的行上触发。例如,如果我将第 3 行移动到第 2 行,则 xxforms-iteration-moved 在第 3 行上触发,但我想重新初始化第 2 行中的组件,并且我的状态保存在 javascript 中。
我认为 xxforms-iteration-moved 应该在改变位置的两行上触发?这实际上是涉及两行的交换。请评论。
编辑:我正在使用 Orbeon Form Runner
I have a XBL component which creates a checkbox control in javascript. Value is set in javascript during the component initialization. Component works well when not used inside repeat but inside repeat when I try to move rows up or down XBL control doesn't change the state.
xxforms-iteration-moved event is fired on the row which is moved but doesn't fire on the row which changes position during this move. For instance, if I move row 3 to row 2 then xxforms-iteration-moved is fired on row 3 but I want to reinitialize components in row 2 as well as my state is saved in javascript.
I think xxforms-iteration-moved should be fired on both rows which changed position? This is really a swap which involves both rows. Please comment.
Edit: I am using Orbeon Form Runner
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
xxforms-iteration-moved 分派到哪些组件取决于如何定义 xxforms-iteration-moved 。现在,它被分派到移动的迭代内的控件。除了
xxforms-iteration-moved
之外,您可能还需要处理xforms-enabled
事件。考虑以下示例:您从包含“a、c、d”的列表开始。如果您在“a”之后插入“b”,则新的“b”将获得一个xforms-enabled
,而“c, d”将分别获得一个xxforms-iteration-moved
。因此,通过对这两个事件做出反应,您应该能够根据需要(重新)初始化您的组件。我应该补充一点,如果您希望您的组件在重复中使用(并且迟早每个组件都会如此),那么现在,由于重复在客户端的工作方式,如果您正在做一些工作来初始化 < 上的组件code>xforms-enabled,您很可能也需要在
xxforms-iteration-moved
上执行此操作。例如,请参阅 这是如何在fr:button
组件中完成的。To what components the
xxforms-iteration-moved
is dispatched is a matter of howxxforms-iteration-moved
is defined. Right now, it is dispatched to controls inside iterations that moved. What you might need is to handle thexforms-enabled
event, in addition toxxforms-iteration-moved
. Consider the following example: you start with a list with "a, c, d". If you insert "b" after "a", then the new "b" gets anxforms-enabled
and "c, d" each get axxforms-iteration-moved
. So by reacting to both events, you should be able to (re)initialize your component as necessary.I should add that if you expect your component to be used in a repeat (and sooner or later every component is), right now, because of how repeats work on the client side, if you are doing some work to initialize the component on
xforms-enabled
, you most likely need to do that as well onxxforms-iteration-moved
. For instance, see how this is done in thefr:button
component.