Function(treeId, treeNode, newName, isCancel)setting.callback.beforeRename

Overview[ depends on jquery.ztree.exedit js ]

Used to capture the event before rename(when input DOM blur or press Enter Key), zTree based on return value to determine whether to allow to rename node.

When node is editing name, press the ESC key to restore the original name and stop edit name.

From v3.5.13, zTree will trigger this callback when user cancel edit name. please see 'isCancel' parameter.

Default: null

Function Parameter Descriptions

treeIdString

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

treeNodeJSON

JSON data object of the node which will be rename.

newNameString

the new name

isCancelBoolean

the status about cancel edit name (v3.5.13+)

isCancel = true means: user cancel edit name. (press ESC or use cancelEditName() function)

isCancel = false means: user submit edit name.

Return Boolean

return true or false

If return false, the treeNode will keep the editing name, don't trigger the 'onRename' callback, and will ignore other enents, until the callback return true.

If returns false, zTree will not set the input box to get focus to avoid the warning message which led to repeated triggering ‘beforeRename’ callback. Please use editName() method to set the input box to get focus when user close the warning message.

Examples of setting & function

1. the length of the new name can't less than 5

function zTreeBeforeRename(treeId, treeNode, newName, isCancel) {
	return newName.length > 5;
}
var setting = {
	edit: {
		enable: true
	},
	callback: {
		beforeRename: zTreeBeforeRename
	}
};
......