views:

2107

answers:

3

I have a div that needs to be moved from one place to another in the DOM. So at the moment I am doing it like so:

flex.utils.get('oPopup_About').appendChild(flex.utils.get('oUpdater_About'));

But, IE, being, well, IE, it doesn't work. It works all other browsers, just not in IE.

I need to do it this way as the element (div) 'oUpdater_About' needs to be reused as it is populated over and over.

So i just need to be able to move the div around the DOM, appendChild will let this happen in all browsers, but, IE.

Thanks in advance!

A: 

make sure to clone the oUpdater_About (with node.cloneNode(true)) this way you get a copy and can reuse the dom-snippet as often as you want (in any browser)

Niko
I think you may have missed the part where sparkyfield said he wanted to *move* elements, not *copy* them.
Jason Musgrove
That's it Jason, cloning the element will mean I have clashing ids, and element. I need one element, to be moved around, not copied.Thanks
sparkyfied
A: 

This post tends to suggest that there is indeed a problem with appendChild with respect to this:

http://metadeveloper.blogspot.com/2007/01/ie-7-appendchild-bug.html

Have you tried cloning it, removing it, then inserting the clone instead?

James

James Wiseman
Yeah, this is another fun one in IE. You must append TRs to a TBODY in IE. Attempting to append them directly to the TABLE will fail.
scunliffe
A: 

You have to remove the node first, before you can append it anywhere else. One node cannot be at two places at the same time.

var node = flex.utils.get('oUpdater_About')
node.parentNode.removeChild(node);
flex.utils.get('oPopup_About').appendChild(node);
port-zero
Cheers guys, thanks for all your help!
sparkyfied
Are you serious? that is wacky! you don't need to do that with regular DOM manipulation. Does the flex wrapper call the same code in IE vs. Other browsers underneath?
scunliffe
@scunliffe: I found no clues to wether you can or cannot re-append a node that is already appended somewhere in the DOM.Do you have a source that could clear that up for me?
port-zero