I
I
Igor Koch2017-07-12 20:29:21
JavaScript
Igor Koch, 2017-07-12 20:29:21

Why does v-on:click work every other time?

I made a small application on vue.js, el.whata.ninja
The point is that each product has combinations of this product, started implementation, and encountered a bug/feature
If you add a line (1), then add a combination (2), to it attribute (3)
Then if you click on the attributes of the combination (4) and the combinations themselves, they are clicked, but somehow through time,
I can’t understand what could be the matter.
0bf05fc1bc114d32bc6eece3117f5baa.png
The method that is executed when the attribute is added:

putAttribute(combination, name){
        console.clear();
        console.log(combination, name);
        if(name == ""){
          return false;
        }
        let combination_index = _.findIndex(this.combinations, function(o) { 
          return o.id == combination;
        });

        let hasValue = _.findIndex(this.combinations[combination_index].attributes, function(o) {
          return o.name == name; 
        }) >= 0;

        console.log(combination_index, hasValue);

        if(hasValue){
          return false;
        }else{
          let new_attribute = {
            name: name,
            value: 'иний'
          };

          this.combinations[combination_index].attributes.push(new_attribute);
        }
      }

Output of computed attributes:
allAtributes(){
        let allAtributes = [];
        _.each(this.combinations, function(combination){
          _.each(combination.attributes, function(attribute){
            allAtributes.push(attribute.name);
          });
        });

        return _.uniq(allAtributes);
      }

Full page code: el.whata.ninja/index.txt
The part responsible for this block is between the comments<!--Attributes--> <!--/Attributes-->

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2017-07-12
@amux

In my opinion, it's banal that the click only works when you hit the cross for sure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question