How do you format the "li" and "a" DOM ​​elements in jsTree by setting your class?

Basically, I have jsTree, and I need to format its li and a DOM elements, adding a custom class to each type. The documentation is not clear how to do this, and as far as I can tell, there is no way to add a custom class, any formatting should be related to overriding the jquery theme or by editing the jsTree source code. I'm fine, either doing this in JSON data, or more efficiently when I declare "types", as shown in the example here:

$("#container").jstree({ "plugins" : ["themes", "json_data", "ui", "themeroller", "types"], "json_data" : {"data": my_json_data}, "core" : { "initially_select" : [ init_id] }, "types" : { "valid_children" : [ "test_type" ], "types" : { "test_type" : { "valid_children" : [ "default", "test_type" ], "icon" : { "image" : "/includes/icon.gif"} } } }, "themes" : { "dots" : true, "icons" : true } }); 
+4
source share
1 answer

If you want to do this in response to JSON, this works for me:

 { "attr": { "class": "some-class1", "id": "node_1" }, "data": { "attr": { "class": "some-class2", "href": "", "title": "node title" } } } 

The first attr refers to the <li> , and the second attr (internal data) refers to the <a> tag.

+3
source

Source: https://habr.com/ru/post/1388244/


All Articles