Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DOMSubtreeModified Event question




I'm dynamically updating the content of a page by manipulating the DOM based on content parsed from an XMLHttpRequest object's responseXML property. Based on the value of the parsed content, a given DOM element (let's say a TD in a table) may or may not get "updated" in the DOM by reassiging its innerText, or by calling a replaceChild() method -- I've tried it both ways.


I'm capturing this "update" event in the page by adding a DOMSubtreeModified event listener on the TD DOM element.

But when capturing the DOMSubtreeModified event on this TD element, the event fires twice. On both event captures, the reported event target is the TD, and not it's childNode[0] (it's innerText).

I'm guessing that the event is firing on first the text node (childNode[0] of the TD), and then the TD itself, but I'm not sure if this is a good guess or not, since I'm not able to successfully add an eventListener to the TD.childNode[0] text node and capture a change to that.

So the questions are:

1) why are two events are being fired?
2) is there any way I can just capture the one event using DOMSubtreeModified in this case?


and on a related note...

3) the W3C spec on Mutation Events shows there is an attrChangeType const (modification, addition, removal) in the MutationEvent interface (http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events- Event); is there any way I can capture this value in javascript? I'm not that good at reading and understanding the W3C specs...

Thanks for any help.



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webcore-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webcore-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.