ember.js - Force ember route to request additional data before rendering -


i'm trying nested route make request additional data, update record, , render view. see below:

// models var attr = ds.attr,     hasmany = ds.hasmany,     belongsto = ds.belongsto  app.list = ds.model.extend({     title: attr('string'),     links: hasmany('link') })  app.link = ds.model.extend({     list: belongsto('list'),     subtitle: attr('string'), })  // json index route {     "list": [         {             "id": 532,             "title": "first list"          },          {             "id": 991,             "title": "second list"          },          {             "id": 382,             "title": "third list"          }     ] }  // json list route - /user/532 {     "list":          {             "id": 532,             "title": "list numero uno",             "links" : [1, 2]          },     "link": [         {             "id": 1,             "subtitle": "this subtitle of firsto listo!"         },         {             "id": 2,             "subtitle": "this subtitle of second part in list"         }     ] }  // routing this.resource('user', function(){     this.route('list', {path: ':id'}) }) app.userroute = ember.route.extend({     model: function(){         return this.store.find('list')     } }) app.userlistroute = ember.route.extend({     model: function(params) {         return this.store.find('list', params.id)     } }) 

i want index route display basic list {{title}}, , clicking on 1 links userlistroute makes ajax call update record additional link data. i've tried adding:

aftermodel: function(modal){     model.reload() } 

to userlistroute uses index route model, , reloads new data. i'm trying avoid this, , make send ajax request , render content - don't want depend on parent model/data.

create different record type, , extend original, or use different model.

app.basiclist = ds.model.extend({  foo: ds.attr() });   app.fulllist = app.basiclist.extend({   //foo   bar: ds.attr() });  app.userlistroute = ember.route.extend({     model: function(params) {         return this.store.find('fulllist', params.id)     } }) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -