我对Javascript和jQuery世界很陌生。我试图在下面的链接中使用jQueryTree表显示一个树表。
http://ludo.cubicphuse.nl/jquery-treetable/
它提供了一些回调功能。
onInitialized回调函数。onNodeCollapse回调函数。onNodeExpand回调函数。onNodeInitialized回调函数。我明白什么是回叫功能。我很难在Javascript中编写代码。
有什么可以帮助我理解我如何处理这些回调函数。我正在尝试获取所选节点的id。
任何帮助都将不胜感激。
发布于 2015-04-08 16:16:30
我使用以下代码段(将行的折叠状态保存到数据库中):
holder.treetable({
onNodeCollapse: function(){
var node = this;
var rowobject = node.row;
// do some stuff with the row or ...
},
})发布于 2013-12-16 17:18:38
初始化树插件:
$("#example-advanced").treetable({ expandable: true });并在tr上添加鼠标向下事件获取节点的id,id存储在data-tt-id数据属性中。
$("#example-advanced tbody").on("mousedown", "tr", function() {
alert(this.getAttribute('data-tt-id'));
});发布于 2013-12-16 16:59:49
要获得所选节点,不需要回调函数。只需获得带有"selected“类的元素(这是插件在选择某些内容时添加的类--至少我在10秒的插件研究中注意到了这一点)。
试试这个:$(".selected").attr("id");
还是需要在select上触发事件?那是另一回事。
https://stackoverflow.com/questions/20616265
复制相似问题