liquor-tree
liquor-tree copied to clipboard
Tree component, integrated with Vuex, doesn't preserve functions in data property
Demo: https://jsfiddle.net/9zLhndy6/20/
Way to reproduce:
- Click button to log out tree state -- function is present
- Change tree state by click on checkbox
- Click button to log out state -- function disappeared
Hi.
It's correct behaviour. Tree is using JSON.stringify
method. That's why functions disappears after change model.
A model is data only. Do not store there anything other than simple data. Use events instead
@amsik It took me a while to find out. Please, add the corresponding note in documentation
Please check MDN: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
Of course, I know how JSON.stringify does work. The issue is it wasn't clear that JSON.stringify is used under hood
Agree with you (about JSON.stringify is used under hood). But I can't understand why you store function for tree item?
I used function in config because it was convenient for my task. And I don't do it now
Could you update docs on this topic?