Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var $tree = $('.jstree', myContext),
- node = $tree.find('li').filter(function() {
- return ( $(this).data().location || {}).id === 158;
- });
- $tree.jstree('select_node', n)
- .on('loaded.jstree', function() {
- // Do something here...
- });
- jQuery("#getStartedTree").jstree("select_node", "#test2");
- The JSON in the TextFile.txt - borrowed from your simple example
- [
- {
- "data" : "A node",
- "children" : [ "Child 1", "Child 2" ]
- },
- {
- "attr" : { "id" : "test1" },
- "data" : {
- "title" : "Long format demo",
- "attr" : { "id" : "test2", "href" : "#" }
- }
- }
- ]
- My tree container is <div id="getStartedTree">
- My jsTree code
- $("#getStartedTree").jstree({
- "themes": {
- "theme": "default",
- "url": "../App_Css/Themes/Default/style.css",
- "dots": true,
- "icons": true
- },
- "json_data": {
- "ajax": {
- "url": "../SiteMaps/TextFile.txt",
- "dataType": "json",
- "data": function(n) {
- return { id: n.attr ? n.attr("id") : 0 };
- }
- }
- },
- "plugins": ["themes", "json_data", "ui"]
- });
- $(treeIdHandle + " li[id=" + nodeId + "] a").click();
- // after the tree is loaded
- $(".jstree").on("loaded.jstree", function(){
- // don't use "#" for ID
- $('.jstree').jstree(true).select_node('ElementId');
- });
- // after the tree is loaded
- $(".jstree").on("loaded.jstree", function(){
- // don't use "#" for ID
- $('.jstree').jstree(true).select_node('ElementId');
- });
- // after the tree is loaded
- $(".jstree").on("loaded.jstree", function(){
- // don't use "#" for ID
- $('.jstree').jstree(true).select_node('ElementId');
- });
- $(".jstree").on("loaded.jstree", function(){
- <?php foreach($tree as $node): ?>
- $('.jstree').jstree(true).select_node('<?=$node?>');
- <?php endforeach;?>
- });
- $('.jstree').jstree(true).select_node('element id');
- jQuery.each(produto.categorias, function(i, categoria) {
- $('#lista-categorias').jstree(true).select_node(categoria.dadoCategoria.id);
- });
- <div class="tree-menu">
- <ul class="menu">
- <li id="node_1">
- Node 1 - Level 1
- <ul class="menu">
- <li id="node_3">
- Node 3 - Level 2
- </li>
- </ul>
- </li>
- <li id="node_2">
- Node 2 - Level 1
- </li>
- </ul>
- </div>
- $('.tree-menu').jstree(true).select_node("node_3");
Add Comment
Please, Sign In to add comment