Skip to content

Instantly share code, notes, and snippets.

@kylecoberly
Created August 19, 2014 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylecoberly/f59a59dedb1603de19cb to your computer and use it in GitHub Desktop.
Save kylecoberly/f59a59dedb1603de19cb to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/tags/v1.0.0/ember.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.0.0-beta.8/ember-data.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script type="text/x-handlebars">
<div>
{{#each}}
<p>Page ID: {{id}}</p>
<p>Page Content ID: {{pageContent.id}}</p>
<p>Title: {{title}}</p>
{{#if pageContent.url}}
<p>URL: {{pageContent.url}}</p>
{{/if}}
{{#if pageContent.text}}
<p>Text: {{pageContent.text}}</p>
{{/if}}
<br />
{{/each}}
</div>
</script>
<script id="jsbin-javascript">
var App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter;
App.ApplicationRoute = Ember.Route.extend({
model: function(){
return this.store.find("page");
}
});
App.Page = DS.Model.extend({
title: DS.attr("string"),
pageContent: DS.belongsTo("pageContent", {async: true, polymorphic: true})
});
App.PageContent = DS.Model.extend({
page: DS.belongsTo("page")
});
App.TextOnly = App.PageContent.extend({
text: DS.attr("string")
});
App.Video = App.PageContent.extend({
url: DS.attr("string")
});
App.Page.FIXTURES = [
{
id: 1,
title: "Introduction",
pageContent: 1,
pageContentType: "textOnly"
},{
id: 2,
title: "Summary",
pageContent: 1,
pageContentType: "Video"
}
];
App.TextOnly.FIXTURES = [
{
id: 1,
text: "Hey buddy",
page: 1
}
];
App.Video.FIXTURES = [
{
id: 1,
url: "www.goodvideo.com",
page: 2
}
];
</script>
</body>
</html>
var App = Ember.Application.create();
App.ApplicationAdapter = DS.FixtureAdapter;
App.ApplicationRoute = Ember.Route.extend({
model: function(){
return this.store.find("page");
}
});
App.Page = DS.Model.extend({
title: DS.attr("string"),
pageContent: DS.belongsTo("pageContent", {async: true, polymorphic: true})
});
App.PageContent = DS.Model.extend({
page: DS.belongsTo("page")
});
App.TextOnly = App.PageContent.extend({
text: DS.attr("string")
});
App.Video = App.PageContent.extend({
url: DS.attr("string")
});
App.Page.FIXTURES = [
{
id: 1,
title: "Introduction",
pageContent: 1,
pageContentType: "textOnly"
},{
id: 2,
title: "Summary",
pageContent: 1,
pageContentType: "Video"
}
];
App.TextOnly.FIXTURES = [
{
id: 1,
text: "Hey buddy",
page: 1
}
];
App.Video.FIXTURES = [
{
id: 1,
url: "www.goodvideo.com",
page: 2
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment