开发者

jQuery based file tree - How to drag and drop files in directories

I am creating a file tree using PHP & jQuery, but I'm having trouble setting it up so I move files around. How might I go about doing this?

So if my directory is:

parent/
   images/
   css/
   js/
       js-test.js

I can move js-test.js to css folder using jQuery. I figure it involves sortable, draggable, and droppable but I cannot get it to work.

Right now I'm using a simple

$(".php-file-tree ul").sortable({
    connectWith : ".php-file-tree ul"   
});

The main problem being I don't want to re-order items and it's a little glitchy. I also want standard behavior allowing 开发者_开发技巧me to drop a file into a closed folder, which doesn't work using this code.


"I also want standard behavior allowing me to drop a file into a closed folder, which doesn't work using this code."

Why not set the on drop event for each folder, removing the item (folder or file) from it's previous list, then adding it to the list hidden inside the closed folder? From what I can guess, the lists you can move it to at the moment are the ones that aren't 'display: none'. So the work around would be to have a drop event for folder items.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜