javascript - Data missing after page refresh -
route:
app.router.map(function() { this.resource("login", { path: "/login"}); this.resource("contacts", { path: "/contacts"}, function () { this.resource("contact", { path: ":contact_id"}, function() { this.route("new"); this.route("edit"); }); }); }); app.contactsindexroute = app.authenticatedroute.extend( { model: function() { return app.contact.find(); } }); app.contactindexroute = app.authenticatedroute.extend( { model: function() { return this.modelfor("contact"); }, setupcontroller: function(controller, model) { controller.set("content", model); } });
controller:
app.contactsindexcontroller = ember.arraycontroller.extend( { setproperties: ['full_name'] }); app.contacteditcontrollerr = ember.objectcontroller.extend( { }); app.contactindexcontroller = ember.objectcontroller.extend( { });
when go #/contacts full list of contacts server. if go #/contacts/1 data if refresh page, data gone , i'm left bare html. question how preserve model in nested resource it's there after page refresh?
i have simulate problem , code works. rest adapter.
http://jsbin.com/ucanam/669#/contacts/1
i think problem returned json. have match following:
several resources
get /contacts
status: 200
{ contacts: [ { id: 1, full_name: 'tom dale' }, { id: 2, full_name: 'yehuda katz'} ] }
unique resource
get /contacts/1
status: 200
{ contact: { id: 1, full_name: 'tom dale' } }
Comments
Post a Comment