1. 程式人生 > >初始化bootstrap treeview樹節點

初始化bootstrap treeview樹節點


                        var id = <%=catid%>;
                      
                    var treeViewObject = $('#tree').data('treeview'),
                        allCollapsedNodes = treeViewObject.getCollapsed(),
                        allExpandedNodes = treeViewObject.getExpanded(),
                        allNodes = allCollapsedNodes.concat(allExpandedNodes);
                    for (var i = 0; i < allNodes.length; i++) {
                           
                        if (allNodes[i].href != ("#"+id))
                        {
                            continue;
                        }
                        var selectNode = allNodes[i];
                        $('#tree').treeview('revealNode', [selectNode, { silent: true }]);
                        treeViewObject.selectNode(selectNode);
                        break;
                    }