ember.js - Emberjs linkTo doesnot update collection i.e department.find() -
learning emberjs
not sure if stackoverflow question or git issue. decided put on stackoverflow first.
here jsbin (open in firefox ..not in chrome raw.github file used)
when click on "<- department" in department template reached after creating new department navigate departments template #each not display newly added department name in list.
it show newly added department on refreshing browser on /departments
update
it seems .set() method working reason new object created returning name , id undefined. might bug ember-model perhaps.
the best solution moment have 2 save methods, 1 on edit controller , adding different save method creating new department.
app.newcontroller = ember.objectcontroller.extend({ save:function(){ var newdep = app.department.create({name: this.get('name')}); newdep.save(); this.get('target').transitionto('department', this.get('model')); } });
here jsbin new controller added - http://jsbin.com/evuloyo/1/edit
end update
it looks when creating record not setting name value correctly on object.
i changed following -
newdepartment = self.get('model'); newdepartment.set('name',this.get('name')); newdepartment.save();
to -
var newdep = app.department.create({name: this.get('name')}); newdep.save();
here updated jsbin http://jsbin.com/ekexino/1/edit
hope helps , works you.
Comments
Post a Comment