[Javascript] Changing an Objects ID and Name

Paul Novitski paul at juniperwebcraft.com
Thu Sep 7 00:06:31 CDT 2006


At 9/6/2006 09:21 PM, Terry Riegel wrote:
>http://clearimageonline.com/pages/start/projects/draganddrop/album.html
...
>function swapNodes(n1, n2, k)
>{
>    var placeHolder = document.createElement(k);
>    n1.parentNode.replaceChild(placeHolder, n1);
>    n2.parentNode.replaceChild(n1, n2);
>    placeHolder.parentNode.replaceChild(n2, placeHolder);
>}
>
>Is there some type of cleanup needed to remove the temporary node
>(placeHolder)? Or is it local to the function and gets removed
>automatically?

Since you're creating the placeholder element in the document, I'm 
sure it's effectively global and will persist beyond the local 
function.  I'd remove it just to be safe.  It might take a huge 
amount of playing around to challenge local memory, but it seems more 
elegant to clean up after each iteration.

By the way, nice user interface, Terry!  Good start!  I'll look 
forward to seeing your application when it's finished.

I have just two suggestions that might already be on your to-do list: 
first that when dragging multiple images you show them all and not 
just the one where dragging was begun, and second that you represent 
the albums graphically, filling them with micro-thumbnails as 
pictures are dragged into them.  It wasn't immediately clear to me 
where to drag the pictures, and it would be cool if this kind of GUI 
could be intuitively obvious.

Regards,
Paul 




More information about the Javascript mailing list