jstree 选中、打开、解绑、清空
$.ajax({
type: "post",
dataType: "json",
url: "<?= url('bom/bomTree') ?>",
data: {'item_id': app.FItemID}
}).success(function (res) {
if (res.code > 0) {
let bom_tree_data = res.data;
let $bom_tree = $('#bom_tree');
$bom_tree.data('jstree', false).empty();//清空
$bom_tree.unbind();//解绑
$bom_tree.jstree({
'core': {
"themes": {dots: true},
"data": bom_tree_data
}
});
if (selected_node) {
let selected_parent = selected_node[0].parent;
$bom_tree.bind('ready.jstree', function (obj, e) {
$bom_tree.jstree('select_node', selected_parent);
$bom_tree.jstree('open_node', selected_parent);
})
}
//绑定
$bom_tree.bind("activate_node.jstree", function (obj, e) {
app.onBomInfo(e.node.id);
});
}
}).error(function () {
layer.msg("获取BOM信息失败");
});