disable hover on the tree?

1,806 views
Skip to first unread message

deitch

unread,
Sep 21, 2010, 11:55:38 AM9/21/10
to jsTree
Is there any way to disable hover on any nodes on the tree
(essentially make it read-only)? I can disable any selection with:

ui: {
select_limit: 0
}

And I can disable an individual type of node (using types plugin)
with:

mytype: {
hover_node: false
}

How do I just disable hovering for the entire tree?

Thanks,
Avi

Niyak

unread,
Sep 22, 2010, 7:58:03 AM9/22/10
to jsTree
Configuring hover_node:false for the default type should do it:

"types": {
"types": {
"default": {
hover_node:false
},
"yourtype" {
...
}
}
}

Or you could just not include the UI plugin, if you don't need
selecting, either.

vakata

unread,
Sep 23, 2010, 4:46:18 AM9/23/10
to jsTree
As Niyak said. :)

deitch

unread,
Sep 23, 2010, 3:14:49 PM9/23/10
to jsTree
Brilliant! It didn't even occur to me to completely disable the UI
plugin. Thanks!

deitch

unread,
Sep 26, 2010, 4:10:04 AM9/26/10
to jsTree
Didn't quite work. If I remove ui from the list of plugins, then both
hover and select are disabled, but clicking is not trapped, and the
event ends up going all the way to the browser, and resetting to the
top of the page. I can get around it by trapping the event, but is
still a kludge.

vakata

unread,
Sep 28, 2010, 3:11:34 PM9/28/10
to jsTree
Hi,

if you remove the UI plugin, you must trap the event (the idea is to
be able to build a menu with clickable links). To trap the event
simply do:

$("container").delegate("a","click",function (e)
{ e.preventDefault(); });

I know it is extra code, but I have no better idea ...

Kindest regards,
Ivan

joolsc...@gmail.com

unread,
Feb 11, 2014, 12:15:27 PM2/11/14
to jst...@googlegroups.com, herz...@googlemail.com
Is it possible to do this in jstree version 3? Niyak's solution no longer works.

Ivan Bozhanov

unread,
Feb 11, 2014, 1:02:46 PM2/11/14
to jst...@googlegroups.com, herz...@googlemail.com
Create a mini plugin and include it:
jQuery.jstree.plugins.nohover = function () { this.hover_node = jQuery.noop; };

and in your config in the plugins array add "nohover":
'plugins': [.... "contextmenu","state","nohover"],

joolsc...@gmail.com

unread,
Feb 12, 2014, 4:20:42 AM2/12/14
to jst...@googlegroups.com, herz...@googlemail.com
Thanks, that works great. :-)
Reply all
Reply to author
Forward
0 new messages