@kimek wrote:
Hello there I’ve spend now 10h on this and still couldn’t figured out what’s going on.
I have 2 components:
{{task-component task=visitor.task}}
{{answer-component task=visitor.task}}
Relationship for models:
Visitor: task: DS.hasMany(‘task’, {inverse: ‘visitor’})
Task: visitor: DS.belongsTo(‘visitor’,{inverse:‘task’})
Everything works fine however when I’m using in task-component:
didReceiveAttrs() { let defaultAnswers = this.get('questions.answers'); // question is service, answer is property only used here this.get('task').forEach(function(item) { item.set('answers',defaultAnswers); // <- this is the issue }); },
It’s binding defaultAnswers to answer attribute for all of task data (visitor have oneToMany relation).
After going to ‘answer-component’ -> answer-item ( which is in handelbars loop for task) -> filling form -> set(‘task.answer’,answer) -> all of task.answer are updated.
Any idea why this happens ?
Posts: 1
Participants: 1