<div class="eletree15"></div>
<script>
var index = 0;
var el = eleTree({
el: '.eletree15',
url: '/eleTree/json/1.json?v=2.0.12',
highlightCurrent: true,
showCheckbox: true,
imgUrl: "/eleTree/images/",
icon: {
fold: "fold.png",
leaf: "leaf.png",
checkFull: ".eletree_icon-check_full",
checkHalf: ".eletree_icon-check_half",
checkNone: ".eletree_icon-check_none",
dropdownOff: ".eletree_icon-dropdown_right",
dropdownOn: ".eletree_icon-dropdown_bottom",
loading: ".eleTree-animate-rotate.eletree_icon-loading1",
},
customText: function(data) {
var s = data.label
if(data.id.toString().indexOf("2")!==-1){
s+=`<i class="eletree_icon-add addchild_test"></i>
<i class="eletree_icon-edit edit_test"></i>
<i class="eletree_icon-delete delete_test"></i>`
}
return s
}
})
el.on('click', function(data) {
if(this.target.classList.contains('addchild_test')){
el.append(data.data.id, {
id: ++index,
label: 'aaa' + index,
})
el.edit(index, 'add_child')
}else if(this.target.classList.contains('edit_test')){
el.edit(data.data.id, 'edit')
}else if(this.target.classList.contains('delete_test')){
el.remove(data.data.id)
}
}).on('add_child', function(data) {
console.log(this)
console.log(data)
setTimeout(() => {
data.load()
}, 500);
}).on('edit', function(data) {
console.log(this)
console.log(data)
setTimeout(() => {
data.load()
}, 500);
})
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60