I'm using the jsTree plugin to list folders in the file system. I need to prevent a user from changing to another node before a certain condition is met.
The below code does not stop the propagation... i saw some solutions with other plugins but this is a simple task it must be possible without other plugins.
$('#jstree').on('select_node.jstree', function (e)
{
if (!changeAllowed()
{
e.preventDefault();
e.stopImmediatePropagation();
}
});
解决方案
Documenting for myself and posterity: you need to include the following function AFTER loading the jstree JS (from: https://github.com/vakata/jstree/blob/master/src/misc.js):
// jstree conditional select node
(function ($, undefined) {
"use strict";
$.jstree.defaults.conditionalselec