Skip to content

Instantly share code, notes, and snippets.

@fishermand46
Created October 19, 2014 16:57
Show Gist options
  • Save fishermand46/713650c20b29a73d76e1 to your computer and use it in GitHub Desktop.
Save fishermand46/713650c20b29a73d76e1 to your computer and use it in GitHub Desktop.

Revisions

  1. fishermand46 created this gist Oct 19, 2014.
    110 changes: 110 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,110 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=utf-8 />
    <title>JS Bin</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
    <script src="http://builds.emberjs.com/tags/v1.7.0/ember.js"></script>
    <script src="http://builds.emberjs.com/canary/ember-data.js"></script>
    </head>
    <body>
    <script type="text/x-handlebars" data-template-name="application">
    <h1>ember-latest jsbin</h1>
    {{outlet}}
    </script>
    <script type="text/x-handlebars" data-template-name="index">
    <h2>Apple Ratings</h2>
    <ul>
    {{#each persistedModels}}
    <li>{{name}}: {{rating}}</li>
    {{/each}}
    </ul>
    {{render "new-apple-form" newApple}}
    </script>

    <script type="text/x-handlebars" data-template-name="new-apple-form">
    {{input placeholder="Name..." value=name}}
    {{input placeholder="Rating..." value=rating}}
    <button {{action "saveApple" item}}>Save</button>
    </script>
    <script id="jsbin-javascript">
    App = Ember.Application.create();
    App.ApplicationAdapter = DS.FixtureAdapter;

    App.Apple = DS.Model.extend({
    name: DS.attr('string'),
    rating: DS.attr('number')
    });

    App.Apple.FIXTURES = [
    {id: 1, name: 'Granny Smith', rating: 7},
    {id: 2, name: 'Fuji', rating: 10},
    {id: 3, name: 'Gala', rating: 6}
    ];

    App.IndexRoute = Ember.Route.extend({
    model: function() {
    return this.store.find('apple');
    }
    });

    App.NewAppleRoute = Ember.Route.extend({
    model: function() {
    return this.store.createRecord('apple');
    }
    });

    App.IndexController = Ember.Controller.extend({
    newApple: function() {
    return this.store.createRecord('apple');
    },
    persistedModels: Ember.computed.filterBy('model', 'isNew', false),
    actions: {
    saveApple: function(model) {
    model.save();
    }
    }
    });
    </script>



    <script id="jsbin-source-javascript" type="text/javascript">App = Ember.Application.create();
    App.ApplicationAdapter = DS.FixtureAdapter;

    App.Apple = DS.Model.extend({
    name: DS.attr('string'),
    rating: DS.attr('number')
    });

    App.Apple.FIXTURES = [
    {id: 1, name: 'Granny Smith', rating: 7},
    {id: 2, name: 'Fuji', rating: 10},
    {id: 3, name: 'Gala', rating: 6}
    ];

    App.IndexRoute = Ember.Route.extend({
    model: function() {
    return this.store.find('apple');
    }
    });

    App.NewAppleRoute = Ember.Route.extend({
    model: function() {
    return this.store.createRecord('apple');
    }
    });

    App.IndexController = Ember.Controller.extend({
    newApple: function() {
    return this.store.createRecord('apple');
    },
    persistedModels: Ember.computed.filterBy('model', 'isNew', false),
    actions: {
    saveApple: function(model) {
    model.save();
    }
    }
    });</script></body>
    </html>
    37 changes: 37 additions & 0 deletions jsbin.pudaz.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    App = Ember.Application.create();
    App.ApplicationAdapter = DS.FixtureAdapter;

    App.Apple = DS.Model.extend({
    name: DS.attr('string'),
    rating: DS.attr('number')
    });

    App.Apple.FIXTURES = [
    {id: 1, name: 'Granny Smith', rating: 7},
    {id: 2, name: 'Fuji', rating: 10},
    {id: 3, name: 'Gala', rating: 6}
    ];

    App.IndexRoute = Ember.Route.extend({
    model: function() {
    return this.store.find('apple');
    }
    });

    App.NewAppleRoute = Ember.Route.extend({
    model: function() {
    return this.store.createRecord('apple');
    }
    });

    App.IndexController = Ember.Controller.extend({
    newApple: function() {
    return this.store.createRecord('apple');
    },
    persistedModels: Ember.computed.filterBy('model', 'isNew', false),
    actions: {
    saveApple: function(model) {
    model.save();
    }
    }
    });