我正在使用jstree插件基于xml文件填充我的树.某些节点文本大于容器div.有没有办法文本包装jstree节点文本?
$(document).ready(function(){
$("#tree").jstree({
"xml_data" : {
"ajax" : {
"url" : "jstree.xml"
},
"xsl" : "nest"
},
"themes" : {
"theme" : "classic",
"dots" : true,
"icons" : true
},
"search" : {
"case_insensitive" : true,
"ajax" : {
"url" : "jstree.xml"
}
},
"plugins" : ["themes", "xml_data", "ui","types", "search"]
}).bind("select_node.jstree", function (event, data) {
$("#tree").jstree("toggle_node", data.rslt.obj);
Run Code Online (Sandbox Code Playgroud)
Has*_*own 15
这适用于3.0.8
.jstree-anchor {
/*enable wrapping*/
white-space : normal !important;
/*ensure lower nodes move down*/
height : auto !important;
/*offset icon width*/
padding-right : 24px;
}
Run Code Online (Sandbox Code Playgroud)
对于那些使用wholerow插件的人;
//make sure the highlight is the same height as the node text
$('#tree').bind('hover_node.jstree', function() {
var bar = $(this).find('.jstree-wholerow-hovered');
bar.css('height',
bar.parent().children('a.jstree-anchor').height() + 'px');
});
Run Code Online (Sandbox Code Playgroud)
对于3.1.1,并且它也可以select_node.jstree使用此函数:
function(e, data) {
var element = $('#' + data.node.id);
element
.children('.jstree-wholerow')
.css('height', element.children('a').height() + 'px')
;
}
Run Code Online (Sandbox Code Playgroud)
jbo*_*eke 10
尝试将以下样式添加到jsTree div的子锚点:
#jstree_div_id a {
white-space: normal !important;
height: auto;
padding: 1px 2px;
}
Run Code Online (Sandbox Code Playgroud)
我的jsTree div样式上也有最大宽度:
#jstree_div_id
{
max-width: 200px;
}
Run Code Online (Sandbox Code Playgroud)