本文介绍了收集物品的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个自定义集合对象,可在添加,删除和修改项目时触发事件.

我想做的是每次添加一个项目时,我的集合对象都会发现该项目的事件,并为找到的每个事件创建侦听器.

这样,收集对象可以侦听其包含的每个项目的事件.如果集合中的某个项目触发了一个事件,则该集合可以触发其自己的事件以将该项目的事件冒泡.

换句话说,我有包含包含集合的集合的集合,并且我想将事件从较低的集合向上传递到较高的集合,直到到达最上层父对象为止.

什么是这样做的好方法?

< edit>我忘了提到我正在使用2.0,因此必须自己进行连接.

Hi,

I have a custom collection object that fires events when items are added, removed and modified.

What I would like to do is each time an item is added, my collection object will discover the events for that item and will create listeners for each event that it finds.

This way the collection object can listen to the events for each item it contains. If an item in the collection fires an event the collection can then fire its own event to bubble that item''s event up.

It other words I have collections that contains collections that contains collections and I want to pass events up from a lower collection up to a higher collection till it reaches the top most parent object.

What''s a good way to do this?

<edit>I forgot to mention that I am using 2.0 and so I have to wire this up myself.

推荐答案




这篇关于收集物品的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 08:29