I am have difficulty setting a belongsTo relationship using ember data. I have a jsfiddle example to demonstrate. My original problem was that I was getting the following error:
Uncaught Error: <DS.StateManager:ember5035> could not respond to event loadedData in state rootState.loaded.updated.inFlight.
This only occurred when I updated the belongsTo relation on the model using the select. That was using Ember Data's built in RestAdapter. In the current example I am using the FixtureAdapter and I can't seem to persist any changes (if you check out the fiddle and edit the name of one the books, you will see that it reverts back to the original name)? They seem to revert as soon as the "server response" is simulated by the adapter? Is there a way to simulate a proper server response?
Also, I am wondering if my woes here are the result of how I've set up the data store transaction. I am using the following approach in the controller:
App.EditBookController = Ember.ObjectController.extend({
enterEditing: function() {
this.transaction = App.router.get('store').transaction();
this.transaction.add(this.get('content'));
},
updateRecord: function() {
this.transaction.commit();
this.transaction = null;
App.router.transitionTo('books');
}
});
Ok, you are using the very edge version of ember-data. This is great, but I have to put myself update too. With the help of @tchak, I can begin to make it working:
http://jsfiddle.net/Sly7/2XHZ2/45/
You will note I'm using App.Book.find() in order to load the fixtures for the first time, and App.Book.all() which seems to be a live Array, so things are kept updated.
I have to going further in order to make the select working.
Ok, my last try for the moment... http://jsfiddle.net/Sly7/2XHZ2/57/
LAST EDIT Got it working by adding the RESTSerializer to the FixtureAdapter. see http://jsfiddle.net/Sly7/2XHZ2/61/