XMLListCollection collectionEvent 上的堆栈溢出

发布于 2024-08-11 20:36:56 字数 454 浏览 7 评论 0原文

我正在开发一个 Flex 3 项目,并且使用一对 XMLListCollection 来管理组合框和数据网格。

组合框部分工作完美。用于此的 XMLListCollection 是静态的。用户选择一个项目,并且在“更改”时,它向第二个集合触发 addItem()。然后,第二个集合的数据网格显示更新后的列表,一切都很好。

然而,数据网格是可编辑的。更复杂的是,我有另一个事件处理程序绑定到第二个 XMLLIstCollection 的“change”事件,并且在该处理程序中,我确实对第二个列表进行了其他更改。这本质上会导致第二个列表“更改”处理程序的无限循环(堆栈溢出:D)。

我不太确定如何处理这个问题。搜索提出了一两个关于自动更新功能的想法,但我无法从中得到太多信息。特别是,该行为仍然存在,一旦我重新启用,就会立即执行“更新”,所以我想我可能做错了。我希望更新能够运行,一般来说,只是不在该代码块期间运行。

感谢您的帮助!

I'm working on a Flex 3 project, and I'm using a pair of XMLListCollection(s) to manage a combobox and a data grid.

The combobox piece is working perfectly. The XMLListCollection for this is static. The user picks an item, and, on "change", it fires off an addItem() to the second collection. The second collection's datagrid then displays the updated list, and all is well.

The datagrid, however, is editable. A further complication is that I have another event handler bound to the second XMLLIstCollection's "change" event, and in that handler, I do make additional changes to the second list. This essentially causes an infinite loop (a stack overflow :D ), of the second lists "change" handler.

I'm not really sure how to handle this. Searching has brought up an idea or two regarding AutoUpdate functionality, but I wasn't able to get much out of them. In particular, the behavior persists, executing the 'updates' as soon as I re-enable, so I imagine I may be doing it wrong. I want the update to run, in general, just not DURING that code block.

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ι不睡觉的鱼゛ 2024-08-18 20:36:56

尝试将行为绑定到自定义事件而不是 CHANGE 事件。

即执行您现在正在执行的操作,但调度并处理自定义事件来完成工作。

Trying to bind the behaviour to a custom event rather than the CHANGE event.

I.e. do what you are doing now, but dispatch and handle a custom event to do the work.

不忘初心 2024-08-18 20:36:56

您考虑过使用 callLater 吗?
直接操作 XMLListCollection 的源 XMLList 是否具有相同的结果?
您是否考虑过类似的事情:

private function changeHandler( event:Event ):void
{
    event.target.removeEventListener( event.type, changeHandler );

    // your code here.

    event.target.addEventListener( event.type, changeHandler );
}

Have you considered using callLater?
Does direct manipulation of XMLListCollection's source XMLList have the same results?
Have you considered something like:

private function changeHandler( event:Event ):void
{
    event.target.removeEventListener( event.type, changeHandler );

    // your code here.

    event.target.addEventListener( event.type, changeHandler );
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文