Function(event, treeId, treeNode, clickFlag)setting.callback.onClick

Overview[ depends on jquery.ztree.core js ]

Used to capture the click event when click node.

If you set 'setting.callback.beforeClick',and return false, zTree will not change selected state, and will not trigger the 'onClick' callback.

Default: null

Function Parameter Descriptions

eventjs event Object

event Object

treeIdString

zTree unique identifier: treeId, easy for users to control.

treeNodeJSON

JSON data object of the node which is clicked

clickFlagNumber

Node is selected or deselected state, please see table below for details

clickFlagselectedMultiautoCancelSelected
&&
event.ctrlKey / metaKey
isSelectedoperate for selected
1truefalsefalsenode is selected (single)
1truefalsetruenode is selected (single)
2truetruefalsenode is selected (multi)
0truetruetruenode is deselected
1falsefalsefalsenode is selected (single)
1falsefalsetruenode is selected (single)
1falsetruefalsenode is selected (single)
0falsetruetruenode is deselected

Examples of setting & function

1. When click node, alert info about 'tId' and 'name'.

function zTreeOnClick(event, treeId, treeNode) {
    alert(treeNode.tId + ", " + treeNode.name);
};
var setting = {
	callback: {
		onClick: zTreeOnClick
	}
};
......