[Vuejs]-Toggle data in vue

0👍

So I come up with this, slightly modified method function and everything works.

    toggle: function (id, lang, type) {
      for(var key in this.item.props[id][lang]) {
         var prop = this.item.props[id][lang][key];
         if(prop.active === true) {
           return [ prop.active = false, this.item.props[id][lang][type].active = true ]
         }
      }
      return this.item.props[id][lang][type].active = true   
    },

I’ve added to each value active: false, so by default all hidden. Though when method gets run, it replaces false to true, if true already set it goes though if statement inside loop and drop old parameter to false and replace new one with true

Leave a comment