2
有一個我創建的select_node事件。但是當我們選擇一個節點時它會發射兩次。在這裏你可以看到我在select_node事件上設置的alter兩次。JSTree select_node事件觸發兩次
另外在JStree初始化過程中,我指定了一個檢查事件。
$('#div_vocabulary_tree').on('select_node.jstree', function (e, data) {
alert("Select Event");
});
這是我JStree初始化代碼
$('#div_vocabulary_tree').jstree({
plugins: ["wholerow", "checkbox", "types", "search"],
"search": {
"case_insensitive": true
},
'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
},
'core': {
themes: {
responsive: !1
},
check_callback: false,
'data': arrayCollectiom,
types: {
"default": {
icon: "fa fa-folder icon-state-warning icon-lg"
},
file: {
icon: "fa fa-file icon-state-warning icon-lg"
}
}
}
}).on("check_node.jstree uncheck_node.jstree", function (e, data) {
//alert(data.node.parents);
//alert(data.node.parent);
//alert(data.node.id + ' ' + data.node.text + (data.node.state.checked ? ' CHECKED' : ' NOT CHECKED'))
})
更多信息 當我鑽下來,我發現,如果我們選擇的第一級(根)節點,它觸發只有一個,如果它的第二級火災2 ..相同,如果在第三級,select_node事件火災3次.. 因此,我有一些與level和select_node事件的連接。那麼,我們如何才能解決這個問題,因爲連接關卡和選擇事件
如果這是你的完整代碼,它只對我發射一次 - https://fiddle.jshell.net/ermakovnikolay/d1buydyp/。 –
您是否嘗試過不同級別的子節點?如果對我來說這很奇怪,爲什麼它的觸發不止一個取決於水平... –
是的,你也可以在那個小提琴中嘗試它們。你應該發佈更多的代碼 –