Issue 319: Moving a newly added node fails if it has never been rendered
Status:  Fixed
Owner: ----
Closed:  Jun 2012
Reported by sh...@thecranes.net.nz, May 30, 2012
What steps will reproduce the problem?
1. perform: newNode = sourceNode.AddChild
2. Move the newly added node: newNode.moce(sourceNode,'after')

Attached file

What is the expected output? What do you see instead?
Expected:
The newly added node is moved correctly.
Currently:
The move fails and then you can't drill into the sourceNode to view the new node even though the sourceNode still displays the expansion icon.

What version of the dynatree and jQuery are you using? 1.21 & 1.7.1 (also tried 1.2 and 1.7.2)
On what operating system and browser? Vista 64bit, Chrome 19, IE9
What DOCTYPE declaration are you using?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Also tried:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Please provide any additional information below.
The only way to get it to work that I have found is to perform an expand on the sourceNode just prior to moving the newNode. This then generates an LI for the newNode and the move works fine. It seems that move assumes that the node being moved must be visible.
_test-ISSUE2.html
3.2 KB   View   Download
Jun 1, 2012
#1 sh...@thecranes.net.nz
I seem to have patched it and it is working for me in Chrome. I haven't tested it extensively. I noticed that you fixed a similar issue in removeChildren for  issue 231 . 

What is happening is that the move is assuming that the node to be moved has been rendered before and has an LI, however, as in my case, if the node is add programatically and immediately moved then it fails. The solution is to skip the steps that remove the current LI or append the current LI, as it doesn't exist yet, then at the end of the move process the parent is rendered and the node is given its LI correctly.

$Version: 1.2.1_rc3$
$Revision: 585, 2012-01-10 00:07:39$

change line 1802 from:
this.parent.ul.removeChild(this.li);

to:

$("li", $(this)).remove();

In addition change line 1850 From:
// Add to target DOM parent
targetParent.ul.appendChild(this.li);

to:

// Child has an <li> tag :
if( this.li ) {
    // Add to target DOM parent
    targetParent.ul.appendChild(this.li);
}
jquery.dynatree.js
99 KB   View   Download
Jun 3, 2012
Project Member #2 moo...@wwwendt.de
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-Release1.2.1
Jun 6, 2012
Project Member #3 moo...@wwwendt.de
This issue was closed by revision r597.
Status: Fixed