dimanche 10 juillet 2016

How to create and restore records using Ember Data

I am new to ember-js i am not able to create and restore data in ember-js using this code please help me.....

Books Name and Author:

  <script type="text/javascript">
     App = Ember.Application.create();

     //The store cache of all records available in an application
     App.Store = DS.Store.extend({
        //adapter translating requested records into the appropriate calls
        adapter: 'DS.FixtureAdapter'
     });

     App.ApplicationAdapter = DS.FixtureAdapter.extend();      

     App.Router.map(function() {
        //posts route
        this.resource('posts');
     });

     App.PostsRoute = Ember.Route.extend({
        model: function() {
           return this.store.find('post');
        }
     });
     App.Post = DS.Model.extend({
        //data Model
        //setting book and author attr as string
        book: DS.attr('string'),
        author: DS.attr('string')
     });

     //attach fixtures(sample data) to the model's class
    App.Post.FIXTURES = [{
        id: 1,
        book: 'Java',
        author: 'Balaguruswamy'},{
        id: 2,
        book: 'C++',
        author: 'Herbert Schildt'},{
        id: 3,
        book: 'jQuery',
        author: 'Ryan Benedetti'
    }];
  </script>




Aucun commentaire:

Enregistrer un commentaire