Ivan,
Great work on this plugin. I have realized most of my needs and am quite happy with how well it works.
I am stuck on the context menu though. It is not showing up when I right click on any nodes or leafs.
A bit of background:
- we don't have a lot of leafs or nodes, at most about 50, usually 20 or less
- we structure the data on the backend quite differently as we have many other needs for it and use a mapper on the front end to convert to the format jsTree prescribes
- the approach we are currently taking is to load it all in one go, let the user make changes and then "save" those changes all at once with a button click, at which time convert it back to the backend structure (I haven't finished this part yet)
Currently, the tree renders fine, opens all nodes on ready.jstree, dnd works very well and I have figured out the style and the root/node/leaf rules using the types (great work by the way). Only issue is right click and no context menu shows up, not even the default Chrome context menu. I also tried this in Safari with the same results.
The code in the onRender of a Backbone.Marionette view:
onRender: function () {
Backbone.Validation.bind(this, {
forceUpdate: true
});
this.stickit();
var tree = this.$el.find('#treeviewData');
tree.on("ready.jstree", function (e, data) {
data.instance.open_all();
});
var data = fieldsAndWellsDataMapper.getTreeViewData(this.model.toJSON());
console.log("mapped data: ", JSON.stringify(data));
tree.jstree({
"core": {
"check_callback": true,
"animation": 0,
"themes": {
"icons": false,
"stripes": false,
"dots": false
},
'data': data
},
"types": {
"#": {
"valid_children": ["field"]
},
"field": {
"valid_children": ["section", "well"]
},
"section": {
"valid_children": ["section", "well"]
},
"well": {
"valid_children": []
}
},
"plugins": [
"themes", "contextmenu", "dnd", "types", "wholerow"
]
});
},
Here's an example of the 'data' I am setting above:
mapped data: [
{"id":"Hondo","text":"Hondo","type":"field","children":[{"id":"200_2-020-3-401003_47","text":"200/2-020-3-401003/47","type":"well"},{"id":"266_6-663-8-383838_38","text":"266/6-663-8-383838/38","type":"well"}]},
{"id":"Unwin","text":"Unwin","type":"field","children":[{"id":"299_9-999-9-999999_99","text":"299/9-999-9-999999/99","type":"well"}]}]