vakata/jstree — Issue #175: Need option to click node's text to toggle node
Author: adrianhumphreys
Created: 2012-02-24 17:37:54+00:00
State: open

Now user must click the disclosure triangle to toggle a node open/closed. This change would allow users to click anywhere in the list item to toggle. Clip of suggested code change follows:

// core functions (open, close, create, update, delete)
$.jstree.plugin("core", {
__init : function () {
this.data.core.locked = false;
this.data.core.to_open = this.get_settings().core.initially_open;
this.data.core.to_load = this.get_settings().core.initially_load;
},
defaults : {
//----------------------- ach20120224 start ------------------//
// If false, user must click on disclosure triangle to
// toggle the node. If true, user can click anywhere in
// the list item to toggle the node.
toggle_on_text : false,
//----------------------- ach20120224 end ------------------//
html_titles	: false,
animation	: 500,
initially_open : [],
initially_load : [],
open_parents : true,
notify_plugins : true,
rtl	: false,
load_open	: false,
strings	: {
loading	: "Loading ...",
new_node	: "New node",
multiple_selection : "Multiple selection"
}
},
_fn : {
init	: function () {
this.set_focus();
if(this._get_settings().core.rtl) {
this.get_container().addClass("jstree-rtl").css("direction", "rtl");
}
//----------------------- ach20120224 start ------------------//
if(this._get_settings().core.toggle_on_text){
this.clicktarget="li";
}else{
this.clicktarget="li > ins";
}
//----------------------- ach20120224 end ------------------//
this.get_container().html("

" + this._get_string("loading") + "

");
this.data.core.li_height = this.get_container_ul().find("li.jstree-closed, li.jstree-leaf").eq(0).height() || 18;

this.get_container()
//----------------------- ach20120224 start ------------------//
//.delegate("li > ins", "click.jstree", $.proxy(function (event) {
.delegate(this.clicktarget, "click.jstree", $.proxy(function (event) {
//----------------------- ach20120224 end ------------------//

etc....