-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
maximum attachment #12
Comments
Hi. You can restore previous
new Vue({
el: '#app',
components: { SlVueTree },
data: function () {
return {
nodes: nodes,
prevNodes: this.cloneDeep(nodes)
}
},
methods: {
onInputHandler(newNodes) {
let slVueTree = this.$refs.slVueTree;
let limitReached = false;
let childrenLimit = 3;
slVueTree.traverse((node) => {
if (node.children.length > childrenLimit) limitReached = true;
});
if (limitReached) {
alert('Limit is reached');
this.nodes = this.cloneDeep(this.prevNodes);
return;
}
this.prevNodes = this.cloneDeep(newNodes);
},
cloneDeep(obj) {
return JSON.parse(JSON.stringify(obj))
}
}
}) |
Add a license
Regarding the example above, it's important to add the <sl-vue-tree
v-model="nodes"
ref="slVueTree"
@select="onSelectHandler"
@drop="onDropHandler"
@toggle="onToggleHandler"
@nodecontextmenu="onNodecontextmenuHandler"
@input.once="onInputHandler"
/> Obviously, it would be great to have full-bodied support for both node drag and node drop validation. New API methods for I'm going to wind up having to roll my own solution for this. Once I get it up and running, I'll share. |
how to set the maximum attachment for each element?
The text was updated successfully, but these errors were encountered: