lundi 10 août 2015

EmberJS client side record management (ember-data)

I have just started trying to use ember-data. I have an ember app for which I need to produce all the data on the client side and then save it all at once. So my object graph has a "Project" as the root object, then a project can have many "Sections" and then each section can have many "Items".

I am up to the stage where I am trying to create Item records on the client side and add them to the correct Section. When I am ready to save the data I just want to use project.save() and have it go and save the object graph instead of saving every time the model changes.

I am trying to look up the section to place the items in by name using store.filter({name:"section1"}) but ember keeps trying to go to the server to look them up. I see this in the console: GET http://localhost:4200/sections?name=Section1 404 (Not Found).

This is what I am trying to do:

store.filter('section', {name:'Section1'}, function(section) {
        return section;
      }).then(function(section)
        {
          var record;
          //create a record
            section.pushObject(record);
          }
        }
      );




Aucun commentaire:

Enregistrer un commentaire