Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I’m using vue-js-toggle-button plugin and I’m wondering how I can change state of unchecked: 'OFF' and checked: 'ON' to stay @change . So when I turn it on it stays on even when I exit the page and return. Addtitonally, when I change from OFF to ON I want working to pass in params as true and when I change to OFF I want working: false

JavaScript
<toggle-button :value="false" @change="postHeight"
     v-bind:labels="{unchecked: 'OFF', checked: 'ON'}"/>

<script>
methods:{
postHeight: async function() {
        try {
          const res = await  axios.post(url,  {
            type: 'height', working: //true if switched to ON, false if OFF, 
          }).then(res => res.data);
        } catch (err) {
            alert("can't post");
        };
      },
}

Thanks so much!

What I have tried:

I'm thinking maybe I get send the state to sessionStorage so it can stay on as long as the page doesn't close.

In regards to passing the params I'm thinking maybe I could access by value as it is currently set to false.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900