How to get the parent folder id by the file id?
We are using jstree for representing the folder and file structure in our web applic开发者_JAVA百科ation. When I move a file from one folder to another folder using drag and drop plugin of jstree, we need to know the folder from which it was moved.
How can we do this?
Below is my code.
<ul>
<li id="phtml_0" rel="root" class="open">
<a href="#"><ins> </ins></a>
<ul>
<li id="phtml_1" rel="folder"> <a><ins> </ins>Folder 1</a></li>
<li id="phtml_2" rel="folder"> <a><ins> </ins>Folder 2</a>
<ul>
<li id="phtml_11" rel="file"><a href="#"><ins> </ins>File 1</a></li>
<li id="phtml_22" rel="file"><a href="#"><ins> </ins>File 2</a></li>
</ul>
</li>
<li id="phtml_3" rel="folder"> <a><ins> </ins>Folder 3</a></li>
</ul>
In above case I have three folders i.e. Folder 1, Folder 2 and Folder 3.
Folder 2 has two files i.e. File 1 and File 2.
When File 1 is moved from Folder 2 to Folder 3, I need a way to find out that it was moved from Folder 2.
Basically I will need the id's of the li element of the containing folder, e.g. for File 2 (when it is moved from Folder 2), I will need the value phtml_2. (2 is the id of the Folder)
Please help.
This worked for me draggedObject.parent().parent().attr('id');
精彩评论