0

I'm trying to update my component with one button instead of two but I can't figure out how to do it

I have these buttons on my Main component

<button @click="subnetp" type="button" class="btn btn-dark">Subnet</button>
<button @click="clear" type="button" class="btn btn-dark">Clear</button>

they call these methods

 subnetp: function(){
      if(this.itsIp(this.ip.dec) && this.itsPrefix(this.ip.dec)){
        this.separete();
        this.showSubnet = true; 
        this.isReverse = false
      }
  },
  clear: function(){
    this.showSubnet = false;
    this.isReverse = true;
  }

When Subnet button is clicked it will show the next component and send some variables as props

 <subnet-app v-if="showSubnet" v-bind:ip='ip,host'></subnet-app>

If I change the info in the component with the buttons I have to click the clear button first and then click subnet to see the component with the info updated.

I want to do this with only one button, but if I try something like this and call the method of clear in the subnet method the button won't work and I still have to click clear first

subnetp: function(){
      this.clear();
      if(this.itsIp(this.ip.dec) && this.itsPrefix(this.ip.dec)){
        this.separete();
        this.showSubnet = true; 
        this.isReverse = false
      }
  }
kingJulian
  • 5,601
  • 5
  • 17
  • 30
mario
  • 41
  • 3
  • what do you mean by "the button won't work" - clicking on 'Subnet' button doesn't render or doesn't update the info inside ? – schellmax Aug 02 '18 at 09:43
  • I mean, the clear function hides and when I add the function clear in the subnetp function it's like if the this.clear() it's ignored – mario Aug 02 '18 at 16:56
  • in case you changed the info that’s rendered inside your ‘subnet-app’ component you need to force re-rendering it, see for example https://stackoverflow.com/q/35105374/176140 – schellmax Aug 03 '18 at 21:11

0 Answers0