Set up the template
In this tutorial, we reference Fuel UX and its dependencies from their CDNs. See the Getting Started page in the documentation for more info.
Create an HTML page. Paste the following for this demo, so it references CSS in the <head>
and the JavaScript files Fuel UX, Bootstrap, and jQuery just above </body>
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<!DOCTYPE html> <html lang="en" class="fuelux"> <head> <meta charset="utf-8"> <title>Fuel UX Test</title> <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/> <link href="http://www.fuelcdn.com/fuelux/3.7.3/css/fuelux.min.css" rel="stylesheet"/> </head> <body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script src="http://www.fuelcdn.com/fuelux/3.7.3/js/fuelux.min.js"></script> </body> </html> |
1 |
<button class="copy-to-clipboard" type="button" data-clipboard-target="setup-code">Copy</button> |
Open the page on your server or with these dependencies set up in a CodePen. If you view the output, you should see a blank page. If you open the browser console, there should be no errors.
Add tree markup
Fuel UX binds to existing markup on the page (just like Bootstrap). Start by placing the tree markup inside of the body
tags:
The tree control is an empty ul
container until data is loaded into the tree via the dataSource method. Data can only be loaded one folder at a time.
The tree uses the markup within data-template="treebranch"
and data-template="treeitem"
at the time of initialization to create it's children.
This example uses the folders selectable option. The recommended markup differs if you do not want folders to be selectable. The main difference is whether the caret is located within tree-branch-name
or not.
The nodes of the tree are very flexible. Based on your data, you can have a virtually unlimited variety of HTML attributes on your nodes. These attributes get added to the tree-branch
and tree-item
elements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<ul id="myTree" class="tree tree-folder-select" role="tree" id="myTree"> <li class="tree-branch hide" data-template="treebranch" role="treeitem" aria-expanded="false"> <div class="tree-branch-header"> <button class="glyphicon icon-caret glyphicon-play"><span class="sr-only">Open</span></button> <button class="tree-branch-name"> <span class="glyphicon icon-folder glyphicon-folder-close"></span> <span class="tree-label"></span> </button> </div> <ul class="tree-branch-children" role="group"></ul> <div class="tree-loader" role="alert">Loading...</div> </li> <li class="tree-item hide" data-template="treeitem" role="treeitem"> <button class="tree-item-name"> <span class="glyphicon icon-item fueluxicon-bullet"></span> <span class="tree-label"></span> </button> </li> </ul> |
http://blog.baibaota.com/690.html
发表评论