互联网技术 · 2024年2月16日

实现amazeui树节点自动展开折叠面板并选择第一个节点

这篇文章主要介绍了amazeui树节点自动展开折叠面板并选中第一个树节点的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

适用amazeui.tree版本:未知(截止到2018年10月)

Amaze UI Tree是Amaze框架的扩展,优点是风格与Amaze框架一致,缺点是很不完善,为了能够在项目中应用,对其核心代码做了修改(另文发表,不在此赘述)。其API中选定树节点的函数多次尝试未果,干脆重写一个。如下:

//默认展开折叠面板
$(“#user-nav”).collapse(open);
//默认点击第一个button
var btnArray = $(“.am-tree-branch-name.click-item”);
btnArray.each(function(i){
//console.log($(this).html());
if ( i == 1 ) {
$(this).click(function(){
$(“.click-item”).removeClass(“am-tree-icon”);
$(“.click-item”).removeClass(“am-icon-check”);

$(this).addClass(“am-tree-icon”);
$(this).addClass(“am-icon-check”);

var obj = new Object();
obj.title = $(this).attr(“data.title”);
obj.level = $(this).attr(“data.level”);
$(this).trigger(tree-click, {
data: obj
});
});
$(this).trigger(click);
}
});

到此这篇关于amazeui树节点自动展开折叠面板并选中第一个树节点的实现的文章就介绍到这了,更多相关amazeui树节点内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

来源:脚本之家

链接:https://www.jb51.net/html5/742049.html

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.