I have this JsTree
with this code:
var Tree = $(\"#MyTree\");
Tree.jstree({
\"core\": {
\"themes\": {
This answer is about the release 3 of jstree - that is what you should use in year 2016. Unfortunaltely your sample code, seems using jstree rel 1, and I can't help you about that.
For release 3
First of all, untie the selected and the checked states (checkbox.tie_selection: false) - see the docs
Then, use the check_node.jstree
event
Working example
var data1 = [{
"id": "W",
"text": "World",
"state": { "opened": true },
"children": [{"text": "Asia"},
{"text": "Africa"},
{"text": "Europe",
"state": { "opened": false },
"children": [ "France","Germany","UK" ]
}]
}];
$('#Tree').jstree({
core: {
data: data1,
check_callback: false
},
checkbox: {
three_state : false, // to avoid that fact that checking a node also check others
whole_node : false, // to avoid checking the box just clicking the node
tie_selection : false // for checking without selecting and selecting without checking
},
plugins: ['checkbox']
})
.on("check_node.jstree uncheck_node.jstree", function(e, data) {
alert(data.node.id + ' ' + data.node.text +
(data.node.state.checked ? ' CHECKED': ' NOT CHECKED'))
})
<link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<div id="Tree"></div>