Created
January 31, 2015 18:09
-
-
Save selvagsz/0e8e5fd0ac1b380a1c03 to your computer and use it in GitHub Desktop.
Recursive Tree in ember - Ember Starter Kit// source http://emberjs.jsbin.com/kemidedopa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Ember Starter Kit</title> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js"></script> | |
<script src="http://builds.emberjs.com/tags/v1.9.0/ember.js"></script> | |
<style id="jsbin-css"> | |
/* Put your CSS here */ | |
html, body { | |
margin: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<h2>Welcome to Ember.js</h2> | |
<ul> | |
{{#each parent in model}} | |
<li>{{parent.name}}</li> | |
{{partial "childpartial"}} | |
{{/each}} | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" id="childpartial"> | |
{{#if parent.children}} | |
<li> | |
<ul> | |
{{#each parent in parent.children}} | |
<li>{{parent.name}}</li> | |
{{partial "childpartial"}} | |
{{/each}} | |
</ul> | |
</li> | |
{{/if}} | |
</script> | |
<script id="jsbin-javascript"> | |
App = Ember.Application.create(); | |
App.Router.map(function() { | |
}); | |
var stubbedModel = [ | |
{ | |
name: 'parent1', | |
children: [ | |
{ | |
name: 'parent1_child1', | |
children: [ | |
{ | |
name: 'parent1_child1_child1', | |
children: [ | |
{ | |
name: 'final' | |
} | |
] | |
}, | |
{ | |
name: 'parent1_child1_child2' | |
} | |
] | |
}, | |
{ | |
name: 'parent1_child2' | |
}, | |
{ | |
name: 'parent1_child3' | |
} | |
] | |
}, | |
{ | |
name: 'parent2' | |
} | |
]; | |
App.ApplicationRoute = Em.Route.extend({ | |
model: function() { | |
return stubbedModel; | |
} | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Ember Starter Kit</title> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css"> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"><\/script> | |
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js"><\/script> | |
<script src="http://builds.emberjs.com/tags/v1.9.0/ember.js"><\/script> | |
</head> | |
<body> | |
<script type="text/x-handlebars"> | |
<h2>Welcome to Ember.js</h2> | |
<ul> | |
{{#each parent in model}} | |
<li>{{parent.name}}</li> | |
{{partial "childpartial"}} | |
{{/each}} | |
{{outlet}} | |
<\/script> | |
<script type="text/x-handlebars" id="childpartial"> | |
{{#if parent.children}} | |
<li> | |
<ul> | |
{{#each parent in parent.children}} | |
<li>{{parent.name}}</li> | |
{{partial "childpartial"}} | |
{{/each}} | |
</ul> | |
</li> | |
{{/if}} | |
<\/script> | |
</body> | |
</html> | |
</script> | |
<script id="jsbin-source-css" type="text/css">/* Put your CSS here */ | |
html, body { | |
margin: 20px; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">App = Ember.Application.create(); | |
App.Router.map(function() { | |
}); | |
var stubbedModel = [ | |
{ | |
name: 'parent1', | |
children: [ | |
{ | |
name: 'parent1_child1', | |
children: [ | |
{ | |
name: 'parent1_child1_child1', | |
children: [ | |
{ | |
name: 'final' | |
} | |
] | |
}, | |
{ | |
name: 'parent1_child1_child2' | |
} | |
] | |
}, | |
{ | |
name: 'parent1_child2' | |
}, | |
{ | |
name: 'parent1_child3' | |
} | |
] | |
}, | |
{ | |
name: 'parent2' | |
} | |
]; | |
App.ApplicationRoute = Em.Route.extend({ | |
model: function() { | |
return stubbedModel; | |
} | |
});</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Put your CSS here */ | |
html, body { | |
margin: 20px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App = Ember.Application.create(); | |
App.Router.map(function() { | |
}); | |
var stubbedModel = [ | |
{ | |
name: 'parent1', | |
children: [ | |
{ | |
name: 'parent1_child1', | |
children: [ | |
{ | |
name: 'parent1_child1_child1', | |
children: [ | |
{ | |
name: 'final' | |
} | |
] | |
}, | |
{ | |
name: 'parent1_child1_child2' | |
} | |
] | |
}, | |
{ | |
name: 'parent1_child2' | |
}, | |
{ | |
name: 'parent1_child3' | |
} | |
] | |
}, | |
{ | |
name: 'parent2' | |
} | |
]; | |
App.ApplicationRoute = Em.Route.extend({ | |
model: function() { | |
return stubbedModel; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment