我想知道您是否可以监听UListElement的元素何时发生了更改(即添加或删除了LIElement )?
UListElement toDoList = query('#to-do-list');
LIElement newToDo = new LIElement();
newToDo.text = "New Task";
toDoList.elements.add(newToDo);
// how do I execute some code once the newToDo has been added to the toDoList?我假设elements.add()是异步的,因为我有ActionScript背景。这是一个有效的假设吗?
发布于 2012-11-21 00:54:04
void setMutationObserver(Element element){
new MutationObserver(mutationHandler)
.observe(element, subtree: true, childList: true, attributes: false);
}
void mutationHandler(List<MutationRecord> mutations,
MutationObserver observer){
for (final MutationRecord r in mutations){
r.addedNodes.forEach((node){
// do stuff here
});
r.removedNodes.forEach((node){
// or here
});
}
}发布于 2012-11-20 21:53:58
element.elements.add(otherElement)是同步的,相当于Javascript中的element.appendChild(otherElement) (即,DOM Level 2 Core : appendChild)。
发布于 2012-11-21 10:54:39
您可能还会对我们与MDV的合作感兴趣:
https://stackoverflow.com/questions/13474034
复制相似问题