我有一个文件夹树结构... 1个块的代码如下:
<div level="1" class="tree-item " ispublic="false" hassubfold="true" isworkspace="0" foldid="3595517$$QC4ixP" dcid="1" proid="54445$$vnwCUD" id="fold_3595517$$QC4ixP">
<div style="padding-left: 30px; float: none; width: auto;" class="tree-row ui-droppable selected">
<span class="openFolder"></span>
<span class="tree-label">1001</span>
</div>
<div class="tree-children" style="display: block;">
<div>
<div level="2" class="tree-item " ispublic="false" hassubfold="false" isworkspace="0" foldid="3711515$$AhXpf3" dcid="1" proid="54445$$vnwCUD" id="fold_3711515$$AhXpf3">
<div style="padding-left: 50px; float: none; width: auto;" class="tree-row ui-droppable">
<a style="visibility:hidden;width:20px;" rel="undefined" title="Expand" class="folder" href="javascript:void(0);"></a>
<a rel="54445$$vnwCUD" class="docList ui-droppable" title="rrrr" href="javascript:void(0);">
<span class="closeFolder "></span>
<span class="tree-label">rrrr</span>
</a>
</div>
<div class="tree-children"></div>
</div>
我需要从包含复选框的列表中拖动文件并放入.tree-row(文件夹树)。当它丢弃d文件时,我需要得到树项目的折叠,我通过下面的代码获得:
event.target.parentElement.attributes['id'].value
使用上面的内容,我得到包含.tree-item的div的多个foldid。我需要获取仅删除文件的文件夹的文件夹ID,该文件夹再次是子文件夹....
function bindDragDropDocEvent(){
$(".tree-row").droppable({
accept: '#fileContent .rows',
tolerance: "touch",
drop:function(event,ui){
event.stopPropagation();
console.log(event);
alert("dropped");
var foldid = event.target.parentElement.attributes['foldid'].value;
if(foldid!=0){
foldid = event.target.parentElement.attributes['foldid'].value;
alert(foldid);
}
},
});
$("#fileContent .rows").draggable({
cursor:'move',
stop:function(event,ui){
event.stopPropagation();
var rowdata = ui.helper.find(':checkbox').data('rowValues');
alert(rowdata.fileName);
},
});
}
任何人都可以请求帮助以获取仅可投放文件夹ID而不是其父级。我用过贪心:真实但没有运气!
答案 0 :(得分:0)
我认为当你放弃它时,你的拖动触摸多个div,这就是为什么你也得到父div的id。 可能的解决方案:
tolerance: "touch",
.tree-row