ember.js - ember-data, Reload model in rootState.error -
i've got ember model, looks (in coffee-script)
app.user = ds.model.extend name: ds.attr('string') age: ds.attr('number) becameerror: -> #f it, give up, reload @reload()
only when call this.reload()
get
error: attempted handle event `reloadrecord` on <app.user:ember255:1> while in state rootstate.error.
what's correct way reload model server?
if want model reload server in event enters error state model definition should this.
app.user = ds.model.extend name: ds.attr('string') age: ds.attr('number) becameerror: -> #f it, give up, reload @get('statemanager').transitionto('loaded.saved') @reload()
the key line being
@get('statemanager')transtionto('loaded.saved')
which seems kind of messy model out of error state. there might prettier way once ember-data gets further along, check docs.
i should mention if want try , recommit changes, can instead uses 1 of these
@get('statemanager').transitionto('loaded.created.uncommitted') # new models @get('statemanager').transitionto('loaded.updated') # updated models
Comments
Post a Comment