0

In a backbone application I am writing I need to combine 2 sets of data into one,

I have the following in my initialise function for a view,

this.model.set('tasks', new Tasks(this.model.get('item_tasks')), {
        silent: true
});


this.model.set('subTasks', new Tasks(this.model.get('sub_item_tasks')), {  
         silent:true   
});

Is there away I can merge these 2 pieces of data into one, to allow me to loop through?

Udders
  • 6,914
  • 24
  • 102
  • 194

1 Answers1

0

Assuming Tasks is a Collection:

var tasks = this.model.get('tasks').toArray().concat(this.model.get('subTasks').toArray());
Ben
  • 10,056
  • 5
  • 41
  • 42