leere Parameter Variable in Glut
Also habe ich einen Router und einige Routen eingerichtet, und das funktioniert größtenteils. Wenn ich # / contacts / 123 (oder was auch immer) lade, gibt ContactIndexRoute ein leeres params-Objekt zurück. Ich bin sicher, dass dies relativ einfach ist, aber ich kann nicht herausfinden, warum. Kann mich jemand in die richtige Richtung weisen? Vielen Dank.
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 all the contacts
var contactPromise = self.contact.store.find('contact');
contactPromise.then(function(data){
self.set('contact', data);
}, undefined);
}
}
});
}
}.observes('socket')
});