javascript - empty params variable in ember -
so i've set router , routes, , works part. when load #/contacts/123 (or whatever) contactindexroute returns empty params object. i'm sure relatively simple, cannot figure out why. can point me in right direction? thanks.
callmonitor.router.map(function(){ this.resource('contacts', function(){ this.resource('contact', {path: '/:contact_id'}, function(){ }) }); }); callmonitor.contactsroute = ember.route.extend({ model: function(){ return this.store.find('contact'); }, setupcontroller: function(controller, contacts) { var socket = callmonitor.socket; controller.set('socket', socket); controller.set('contact', contacts); }, rendertemplate: function(){ this._super(this, arguments); this.render('contacts', { into: 'application', outlet: 'contacts', controller: 'contacts' }); } }); callmonitor.contactindexroute = ember.route.extend({ model: function(params){ return this.store.find('contact', params.contact_id); }, rendertemplate: function(){ this._super(this, arguments); this.render('contact', { outlet: 'points', into: 'contacts', controller: 'contactsindex' }) }, setupcontroller: function(controller, contact) { controller.set('contact', contact); } }); callmonitor.contactscontroller = ember.arraycontroller.extend({ actions: { getpoints: function(data){ this.transitiontoroute('contact', data.id); console.log('the data is' + data ); } }, socketdidchange: function(){ var socket = this.get('socket'), self = this; if(socket) { socket.on('call', function (data) { if(data.contactpointid){ } else if (data.contactid) { var contacttoupdate = self.contact.filter(function(item) { return item.id == data.contactid; }); if(contacttoupdate.length) { contacttoupdate[0].reload(); } else { // reload contacts var contactpromise = self.contact.store.find('contact'); contactpromise.then(function(data){ self.set('contact', data); }, undefined); } } }); } }.observes('socket') });
params passed route defines slug. meaning if define slug on resource exists on resource, , not routes. if it's defined on route under resource lives on route.
callmonitor.contactroute = ember.route.extend({ model: function(params){ return this.store.find('contact', params.contact_id); }, rendertemplate: function(){ this._super(this, arguments); this.render('contact', { outlet: 'points', into: 'contacts', controller: 'contactsindex' }) }, setupcontroller: function(controller, contact) { controller.set('contact', contact); } });
Comments
Post a Comment