jstree selects child nodes without cascading to select parent nodes

jstree3.3.3 will select its parent node by default when the child node is selected. To remove this function, make the following modifications to the source code:

Comment out:

Lines 5050 to 5079 of code.

 

// apply up
if(s.indexOf('up') !== -1) {
	while(par && par.id !== $.jstree.root) {
		c = 0;
		for(i = 0, j = par.children.length; i < j; i++) {
			c += m[par.children[i]].state[ t ? 'selected' : 'checked' ];
		}
		if(c === j) {
			par.state[ t ? 'selected' : 'checked' ] = true;
			sel[par.id] = true;
			//this._data[ t ? 'core' : 'checkbox' ].selected.push(par.id);
			tmp = this.get_node(par, true);
			if(tmp && tmp.length) {
				tmp.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
			}
		}
		else {
			break;
		}
		par = this.get_node(par.parent);
	}
}

cur = [];
for (i in sel) {
	if (sel.hasOwnProperty(i)) {
		cur.push(i);
	}
}
this._data[ t ? 'core' : 'checkbox' ].selected = cur;

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326840234&siteId=291194637