Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. // require() some stuff from npm (like you were using browserify)
  2. // and then hit Run Code to run it on the right
  3. var TreeModel = require('tree-model'),
  4. tree = new TreeModel(),
  5. root = tree.parse(
  6. {
  7. flow: 'row',
  8. index: 0,
  9. templateUrl: 'test',
  10. children:
  11. [
  12. {
  13. flow: '',
  14. index: 1,
  15. templateUrl: 'new',
  16. children: []
  17. },
  18. {
  19. flow: '',
  20. index: 2,
  21. templateUrl: 'info',
  22. children: []
  23. }
  24. ]
  25. }/*,
  26. {
  27. flow: '',
  28. index: 2,
  29. templateUrl: 'info',
  30. children: []
  31. }*/
  32. );
  33.  
  34. var nodeTest = root.first(function (node) {
  35. if (node.model.index === 0) {
  36. return true;
  37. }
  38. });
  39.  
  40. console.log("nodeTest", nodeTest);
  41.  
  42. var nodeNew = root.first(function (node) {
  43. //console.log(node);
  44. if (node.model.index === 1) {
  45. return true;
  46. }
  47. });
  48.  
  49. //console.log(found1);
  50.  
  51. var nodeInfo = root.first(function (node) {
  52. if (node.model.index === 2) {
  53. return true;
  54. }
  55. });
  56.  
  57. //console.log(found2);
  58.  
  59. nodeInfo.addChild(nodeNew);
  60.  
  61. nodeNew.addChild(nodeTest);
  62.  
  63. console.log(nodeInfo);
  64.  
  65. root.walk(function (node) {
  66. //console.log(node);
  67. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement