add callbacks on tree

This commit is contained in:
Leopoldthecoder
2016-10-05 23:06:17 +08:00
parent fbd50ae343
commit ed8168bc2c
4 changed files with 72 additions and 17 deletions

View File

@@ -46,11 +46,31 @@
$tree: null,
expanded: false,
childrenRendered: false,
showCheckbox: false
showCheckbox: false,
oldChecked: null,
oldIndeterminate: null
};
},
watch: {
'node.indeterminate'(val) {
this.handleSelectChange(this.node.checked, val);
},
'node.checked'(val) {
this.handleSelectChange(val, this.node.indeterminate);
}
},
methods: {
handleSelectChange(checked, indeterminate) {
if (this.oldChecked !== checked && this.oldIndeterminate !== indeterminate) {
this.$tree.$emit('check-change', this.node.data, checked, indeterminate);
}
this.oldChecked = checked;
this.indeterminate = indeterminate;
},
handleExpandIconClick(event) {
let target = event.target;
if (target.tagName.toUpperCase() !== 'DIV' &&
@@ -65,6 +85,7 @@
this.childrenRendered = true;
});
}
this.$tree.$emit('node-click', this.node.data);
},
handleUserClick() {