The question is very simple, im trying to echo with PHP a JSTree List Item that is checked by default.
According to all the information that i've found on similar issues, I should be able to echo an active list item by just adding class="jstree-checked"
but its not working for me.
This is the code that I'm currently using. This code shows up a list item that is not checked.
echo '<li class="jstree-checked" id="id">List Item that should be checked on load but its not</li>';
This is my JS Tree code
<script>
var select_data = '';
$(function () {
$("#tree").jstree({
"checkbox": {
'keep_selected_style': false,
'three_state': false,
'cascade': '',
},
"plugins": ["checkbox"],
});
$("#tree").bind("changed.jstree",
function (e, data) {
console.log(data);
select_data = JSON.stringify(data.selected);
}
);
});
$.jstree._reference('#tree').check_node('#test');
function upload() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert(this.responseText);
}
};
var url = "../../jstree/ajax.php?select_data=" + select_data;
xhttp.open("GET", url, true);
xhttp.send();
}
</script>