Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have an application using vue.js. I generate a list of results using v-for in an array of objects. when I update the object inside nth item in array, using underscore _.extend, the view of project does not update. There is a solution for this problem at http://vuejs.org/guide/reactivity.html which indicates to use _.extend like this:

this.results.displayed[key] = _.extend({}, this.results.displayed[key], detail.items);

but the problem is when I use extend like it said, it does not update the view.

share|improve this question
    
There's not enough information to figure out what is wrong. Can you recreate this in a fiddle? – David K. Hess Feb 7 at 17:50
up vote 2 down vote accepted

Vue is unable to detect the change when you set a new item by array index. To get around this, you can use the $set() method that Vue adds to the array.

var newObject = _.extend({}, this.results.displayed[key], detail.items);
this.results.displayed.$set(key, newObject);

More info here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.