-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relations lost on page reload #23
Comments
@adick I'm going through a similar issue, I create a record and all good. But when I add/edit some of the record and save, all the changes disappear after reloading the page. |
I think this is the same issue I've been experiencing. What's weird is, on your jsbin, if I create a list, and add some items, then refresh, the items are still there. As you specify, it's the adding items after refresh that cause the relationships to get wiped out on refresh. Basically, adding the new items after refresh completely wipes out the "items" hasMany property from the browser storage. The issue I was running into, though, was that the "items" field (or whatever hasMany property I'm using) doesn't appear to be saved properly to begin with. I'm not quite good enough with all this, though, to know whether I was screwing something up, or it was a bug with LSA. Glad to hear I might not have been fully to blame. :) /edit: Also, it looks like you don't have to add items to the list before refreshing. If you add a list, then refresh, then add items, then refresh again, those items will be gone. I'm investigating further, but I don't think I know enough about all of this to have much hope at finding the actual issue, let alone resolving it. /edit 2: Further investigation. So, it would appear that when you add an item to the hasMany property of a fresh record (read: before you refresh the page, reloading it from localstorage), it would appear that it is saving the children of that property by id:
If, however, you add items after refreshing, it adds them as embedded items:
/edit: So, the above only happens if you:
If you create a list, add items, refresh, then add more items, the "items" property of the list is simply not saved at all. |
@justonross thanks for investigating it! It may have also something to do with ember data, I'm not sure if this is caused by the localstorage adapter. This whole thing (in conjunction with ember data) bugged me long enough to give up... now I use ember model with server-side session storage instead. https://github.com/ebryn/ember-model |
@adick @justinross After investigating further I found that the issue for me at least was related with the serialization of the object. The call to
Now it is saving the changes and persisting across refresh. |
fyi, #30 will fix this. |
This problem is back, for me at least...
The relations does not persist through a reload of the application... |
They discussed it here as well: http://discuss.emberjs.com/t/ember-data-fixture-adapter-saving-record-loses-has-many-relationships/2821/3 I tried implementing the new serializeHasMany, which showed me that the actual data in the localStorage is empty in the relation:
The app works like it should though - seems that the models know about the relations. |
Updated to ember-data 1.0.0-beta.11 - still the same issue. |
It feels like there is something wrong with what I am doing when I load my fixtures. |
I also had to implement a new See below:
|
Added a separate issue on this: Feel free to point me to ember-data if that's the issue. |
Models:
Actions:
When you add some items to the list, they get added correctly and if you reload the page, the list and the items are loaded correctly.
BUT if you then add more items to the list and reload the page again, all relations are lost! The items remain in the store, but in the list the items property is gone.
Demo page: http://jsbin.com/oKuPev/72
To reproduce:
The text was updated successfully, but these errors were encountered: