jstree选中子节点不级联选中父节点

jstree3.3.3默认在选中子节点时会选中其父节点,若要去除此功能对源码做以下修改:

注释掉:

5050  至 5079行的代码。

// 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;

猜你喜欢

转载自krs.iteye.com/blog/2364053