How to reload an ember data record?

I'm using the new router and ember data rev 11.

I have a need to force ember-data to re-load data for a record from the server. Using App.MyRecord.find(2) in setInterval function loads the data from the client local store.

How can I reload the data from the server?

Answers


I just pushed record.reload() to Ember Data. This will ask the adapter to reload the data from the server and update the record with the new data.

Constraints:
  • You can only call reload() on a record if it has completed loading and has not yet been modified. Otherwise, the returned data will conflict with the modified data. In the future, we will add support for a merge hook to address these sorts of conflicts, which will allow reload() in more record states.
  • If you call reload() and change or save the record before the adapter returns the new data, you will get an error for the same reason. The error currently looks something like Attempted to handle event 'reloadRecord' on <Person:ember263:1> while in state rootState.loaded.updated.uncommitted.. Basically, this means that your record was in the "updated but uncommitted" state, and you aren't allowed to call reload() outside of the "loading and unmodified" state.

Need Your Help

Upgrading to .NET 4.5: An ItemsControl is inconsistent with its items source

c# wpfdatagrid .net-4.5

I'm building an application, which uses many ItemControls(datagrids and listviews). In order to easily update these lists from background threads I used this extension to ObservableCollections, whi...

How do you set a conditional in python based on datatypes?

python types conditional

This question seems mind-boggling simple, yet I can't figure it out. I know you can check datatypes in python, but how can you set a conditional based on the datatype? For instance, if I have to wr...